﻿#include "CSqlOper.h"
#include "CDevDataBase.h"
CSqlOper::CSqlOper()
{
}

CSqlOper::~CSqlOper()
{
}

QString selDeviceInfo(QString sId, int & nType, QString & sErr)
{
	QString sGuid = "";
	CDatabaseExecData cData;
	cData.sTableName = "prob_device_info";
	cData.sSql = "select * from prob_device_info where ID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("ID");
	cData.vecValue.push_back(sId);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErr = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	if (vecDataInfo.size() > 0)
	{
		sGuid= vecDataInfo[0].value("GUID").toString().trimmed();
		nType = vecDataInfo[0].value("DEVICE_TYPE").toString().toInt();
	}
	return sGuid;
}

bool intsertDeviceInfo(CDevDataBase* pDevDataRob, QString& sErr)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_device_info";
	cData.sSql = "INSERT INTO prob_device_info (GUID,ID,NAME,DEVICE_TYPE)"
		"values(?,?,?,?)";
	cData.addValue("GUID", pDevDataRob->m_sDevGuid);
	cData.addValue("ID", pDevDataRob->m_sId);
	cData.addValue("NAME", pDevDataRob->m_sRobName);
	cData.addValue("DEVICE_TYPE", QString::number(0));
	return CPublicData::instance().m_pSqlDllOper->exec(cData);
}


bool selRobHostById(CDevDataBase * pDevDataRob, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_robot_basic_config";
	cData.sSql = "select * from prob_robot_basic_config where ROBOT_HOST_ID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("ROBOT_HOST_ID");
	cData.vecValue.push_back(pDevDataRob->m_sDevGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		pDevDataRob->m_sRobotIp=vecDataInfo[i].value("IP_ADDRESS").toString();
		pDevDataRob->m_sRobotPort=vecDataInfo[i].value("PORT_NUMBER").toString();
		pDevDataRob->m_sRobName=vecDataInfo[i].value("ROBOT_NAME").toString();
		pDevDataRob->m_dRobRunSpeed = vecDataInfo[i].value("ROBOT_RUN_SPEED").toInt();
		pDevDataRob->m_dRobRunSpeedZ = vecDataInfo[i].value("ROBOT_RUN_SPEEDZ").toDouble();
		pDevDataRob->m_nDeviceEnum = vecDataInfo[i].value("DEVICE_ENUM").toInt();
		pDevDataRob->m_nRobType = vecDataInfo[i].value("ROBOT_TYPE").toInt();
		pDevDataRob->m_dSafeDistance = vecDataInfo[i].value("SAFE_DISTANCE").toDouble();
		pDevDataRob->m_nRobWorkType = vecDataInfo[i].value("ROBOT_WORK_TYPE").toInt();
		pDevDataRob->m_dCorse = vecDataInfo[i].value("CORSE").toDouble();
		pDevDataRob->m_nProximitySensorOffset = vecDataInfo[i].value("PROXIMITY_SENSOR_OFFSET").toInt();
		pDevDataRob->m_nNo2LabelOffset = vecDataInfo[i].value("NO2_LABEL_OFFSET").toInt();
		pDevDataRob->m_nIsOpenAutoCharge = vecDataInfo[i].value("IS_OPEN_AUTO_CHARGEL").toInt();
		pDevDataRob->m_nAutoChargeThreshold = vecDataInfo[i].value("AUTO_CHARGE_THRESHOLD").toInt();
		pDevDataRob->m_dReturnSpeed = vecDataInfo[i].value("RETURN_SPEED").toDouble();
		pDevDataRob->m_dFrontObstacleAvoidance = vecDataInfo[i].value("FRONT_OBSTACLE_AVOIDANCE").toDouble();
		pDevDataRob->m_dBackObstanceAvidance = vecDataInfo[i].value("BACK_OBSTACLE_AVOIDANCE").toDouble();
		pDevDataRob->m_dChargeCutOffThreshold = vecDataInfo[i].value("CHARGE_CUTOFF_THRESHOLD").toDouble();
		pDevDataRob->m_dChargeCutOffVolTage = vecDataInfo[i].value("CHARGE_CUTOFF_VOLTAGE").toDouble();
		pDevDataRob->m_dHoldingAddPowerThreshold = vecDataInfo[i].value("HOLDING_ADDPOWER_THRESHOLD").toDouble();
		pDevDataRob->m_dHoldingAddPowerVoltage = vecDataInfo[i].value("HOLDING_ADDPOWER_VOLTAGE").toDouble();
		pDevDataRob->m_dTaskEleQuantityThreshold = vecDataInfo[i].value("TASK_ELE_QUANTITY_THRESHOLD").toDouble();
		pDevDataRob->m_dTaskEleQuantityVoltage = vecDataInfo[i].value("TASK_ELE_QUANTITY_VOLTAGE").toDouble();
		pDevDataRob->m_dForceChargeThreshold = vecDataInfo[i].value("FORCE_CHARGE_THRESHOLD").toDouble();
		pDevDataRob->m_dForceChargeVoltage = vecDataInfo[i].value("FORCE_CHARGE_VOLTAGE").toDouble();
		pDevDataRob->m_dChargeFallLoopCount = vecDataInfo[i].value("CHARGE_FAIL_LOOP_COUNT").toDouble();
		pDevDataRob->m_dChargeCommunicationDelay = vecDataInfo[i].value("CHARGE_COMMUNICATION_DELAY").toDouble();
		pDevDataRob->m_dChargeAutoRetornDistance = vecDataInfo[i].value("CHARGE_AUTO_RETORN_DISTANCE").toDouble();
		pDevDataRob->m_dLevelOneSpeedCut = vecDataInfo[i].value("LEVEL_ONE_SPEED_CUT").toDouble();
		pDevDataRob->m_dLevelTwoSpeedCut = vecDataInfo[i].value("LEVEL_TWO_SPEED_CUT").toDouble();
		pDevDataRob->m_dDriveMotorUpperCurrent = vecDataInfo[i].value("DRIVE_MOTOR_UPPER_CURRENT").toDouble();
		pDevDataRob->m_dDriveMotorCurrentSleep = vecDataInfo[i].value("DRIVE_MOTOR_CURRENT_SLEEP").toDouble();
		pDevDataRob->m_dDriveMotorUpperTorque = vecDataInfo[i].value("DRIVE_MOTOR_UPPER_TORQUE").toDouble();
		pDevDataRob->m_dDriveMotorTorqueSleep = vecDataInfo[i].value("DRIVE_MOTOR_TORQUE_SLEEP").toDouble();
		pDevDataRob->m_dDriveMotorUpperTemp = vecDataInfo[i].value("DRIVE_MOTOR_UPPER_TEMP").toDouble();
		pDevDataRob->m_dDriveMotorTempSleep = vecDataInfo[i].value("DRIVE_MOTOR_TEMP_SLEEP").toDouble();
		pDevDataRob->m_dLiftMotorUpperCurrent = vecDataInfo[i].value("LIFT_MOTOR_UPPER_CURRENT").toDouble();
		pDevDataRob->m_dLiftMotorCurrentSleep = vecDataInfo[i].value("LIFT_MOTOR_CURRENT_SLEEP").toDouble();
		pDevDataRob->m_dLiftMotorUpperTorque = vecDataInfo[i].value("LIFT_MOTOR_UPPER_TORQUE").toDouble();
		pDevDataRob->m_dLiftMotorTorqueSleep = vecDataInfo[i].value("LIFT_MOTOR_TORQUE_SLEEP").toDouble();
		pDevDataRob->m_dLiftMotorUpperTemp = vecDataInfo[i].value("LIFT_MOTOR_UPPER_TEMP").toDouble();
		pDevDataRob->m_dLiftMotorTempSleep = vecDataInfo[i].value("LIFT_MOTOR_TEMP_SLEEP").toDouble();
		pDevDataRob->m_dLiftMotorSleepSet = vecDataInfo[i].value("LIFT_MOTOR_SPEED_SET").toDouble();
		pDevDataRob->m_dOneClickBaceLocation = vecDataInfo[i].value("ONE_CLICK_BACK_LOCATION").toDouble();

		pDevDataRob->m_dAutoSwitchOpenBatteryThre = vecDataInfo[i].value("AUTO_SWITCH_OPEN_BATTERY_THRE").toDouble();
		pDevDataRob->m_dAutoSwitchOpenVolThre = vecDataInfo[i].value("AUTO_SWITCH_OPEN_VOL_THRE").toDouble();
		pDevDataRob->m_dIsAutoFlush = vecDataInfo[i].value("IS_AUTO_FLUSH").toDouble();
		pDevDataRob->m_nFlushRFID1 = vecDataInfo[i].value("FLUSH_RFID1").toInt();
		pDevDataRob->m_nFlushRFID2 = vecDataInfo[i].value("FLUSH_RFID2").toInt();
		pDevDataRob->m_dFlushPlaceOffset = vecDataInfo[i].value("FLUSH_PLACE_OFFSET").toDouble();
		pDevDataRob->m_nVoiceOffset = vecDataInfo[i].value("VOICE_OFFSET").toInt();
		pDevDataRob->m_nVoiceAverigeTime = vecDataInfo[i].value("VOICE_AVERIGE_TIME").toInt();
		pDevDataRob->m_nTempOffset = vecDataInfo[i].value("TEMP_OFFSET").toInt();
		pDevDataRob->m_nHumOffset = vecDataInfo[i].value("HUM_OFFSET").toInt();
		pDevDataRob->m_nGasOffset = vecDataInfo[i].value("GAS_OFFSET").toInt();
		pDevDataRob->m_nCoOffset = vecDataInfo[i].value("CO_OFFSET").toInt();
		pDevDataRob->m_nPM25Offset = vecDataInfo[i].value("PM25_OFFSET").toInt();
		pDevDataRob->m_nPM10Offset = vecDataInfo[i].value("PM10_OFFSET").toInt();
		pDevDataRob->m_nHumEnable = vecDataInfo[i].value("HUM_ENABLE").toInt();

		//pDevDataRob->m_sRobObstacleCfg.set(vecDataInfo[i].value("OBSTACLE_CFG").toString());

		//冲洗配置
		pDevDataRob->m_nIsHaveFlush = vecDataInfo[i].value("IS_HAVE_FLUSH").toInt();
		pDevDataRob->m_nFlushBlong = vecDataInfo[i].value("FLUSH_BLONG").toInt();

		//避障
		QString sObstacle = vecDataInfo[i].value("OBSTACLE_CFG").toString();
		QStringList slistObstacle = sObstacle.split(";");
		for (int i = 0; i < slistObstacle.size(); i++)
		{
			QString sItem = slistObstacle[i];
			QStringList slistItem = sItem.split(",");
			if (slistItem.size() > 1)
			{
				pDevDataRob->m_mapRobObstacle.insert(slistItem[0].toDouble(), slistItem[1].toInt());
			}
		}
	}
	return bRet;
}

bool selectRobRollerNoConfigByID(CDevDataBase * pDevDataRob, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_roller_config";
	cData.sSql = "select * from prob_roller_config where DEV_GUID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("DEV_GUID");
	cData.vecValue.push_back(pDevDataRob->m_sDevGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		SRollerNo sRollerNo;
		sRollerNo.m_nRollerNoA = vecDataInfo[i].value("ROLLER_A").toInt();
		sRollerNo.m_nRollerNoB = vecDataInfo[i].value("ROLLER_B").toInt();
		sRollerNo.m_sRollerDescA = vecDataInfo[i].value("ROLLER_DESC_A").toString();
		sRollerNo.m_sRollerDescB = vecDataInfo[i].value("ROLLER_DESC_B").toString();
		pDevDataRob->m_mapRollerConfig.insert(vecDataInfo[i].value("POS_VALUE").toDouble(), sRollerNo);
	}
	return bRet;
}

bool selRobPanTiltById(CDevDataBase * pDevDataRob, QString & sErrMsg)
{
	CDevDataCam *pDevDataCam = pDevDataRob->m_pDevDataCam;
	CDatabaseExecData cData;
	cData.sTableName = "prob_pan_tilt_config";
	cData.sSql = "select * from prob_pan_tilt_config where ROBOT_HOST_ID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("ROBOT_HOST_ID");
	cData.vecValue.push_back(pDevDataRob->m_sDevGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		pDevDataCam->m_sRobHostGuid = vecDataInfo[i].value("ROBOT_HOST_ID").toString();
		pDevDataCam->m_sCamerGuid = vecDataInfo[i].value("PAN_TILT_ID").toString();
		pDevDataCam->m_sCamerName = vecDataInfo[i].value("PAN_TILT_NAME").toString();
		pDevDataCam->m_sCamerType = vecDataInfo[i].value("PAN_TILT_TYPE").toString();
		pDevDataCam->m_sIRCamerCode = vecDataInfo[i].value("IR_CAMERA_CODE").toString();
		pDevDataCam->m_sImageCamerCode = vecDataInfo[i].value("IMAGE_CAMERA_CODE").toString();
		pDevDataCam->m_sAudioDeviceCode = vecDataInfo[i].value("AUDIO_DEVICE_CODE").toString();
		pDevDataCam->m_sCamerIp = vecDataInfo[i].value("PAN_TILT_IP").toString();
		pDevDataCam->m_nCamerPort = vecDataInfo[i].value("PAN_TILT_PORT").toInt();
		pDevDataCam->m_sUserName = vecDataInfo[i].value("USER_NAME").toString();
		pDevDataCam->m_sPassWord = vecDataInfo[i].value("PASSWORD").toString();
		pDevDataCam->m_sRecordPath = vecDataInfo[i].value("MANUAL_RECORD_PATH").toString();
		pDevDataCam->m_sCamerObsConfig = vecDataInfo[i].value("PAN_TILT_OBS_CONFIG").toString();
		pDevDataCam->m_sRtspUrlIr = vecDataInfo[i].value("HW_RTSP_URL").toString();
		pDevDataCam->m_sRtspUrlImg = vecDataInfo[i].value("GQ_RTSP_URL").toString();
		pDevDataCam->m_nBroadcastTime = vecDataInfo[i].value("BROADCAST_TIME").toInt();
	}
	return bRet;
}

bool selectRobSensorByID(CDevDataBase * pDevDataRob, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_sensor_config";
	cData.sSql = "select * from prob_sensor_config where ROBOT_HOST_ID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("ROBOT_HOST_ID");
	cData.vecValue.push_back(pDevDataRob->m_sDevGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		SSensorInfo sensorInfo;
		sensorInfo.m_sGuid = vecDataInfo[i].value("GUID").toString();
		sensorInfo.m_sSensorName = vecDataInfo[i].value("SENSOR_NAME").toString();
		sensorInfo.m_sSnesorType = vecDataInfo[i].value("SENSOR_TYPE_CODE").toString();
		sensorInfo.m_bEnaled = vecDataInfo[i].value("SENSOR_ENABLED").toInt();
		pDevDataRob->m_vecSensor.push_back(sensorInfo);
	}
	return bRet;
}

bool selectIoByID(CDevDataBase * pDevDataRob, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_io_allocation_table";
	cData.sSql = "select * from prob_io_allocation_table where ROBOT_HOST_ID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("ROBOT_HOST_ID");
	cData.vecValue.push_back(pDevDataRob->m_sDevGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	QMap<int, SAddrData> m_mapAddrDataR;        //读 测点序号 测点地址结构体
	QMap<int, SAddrData> m_mapAddrDataW;        //写 测点序号 测点地址结构体
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		SAddrData stAddrData;
		stAddrData.m_sAddrData = vecDataInfo[i].value("START_ADDRESS").toString();
		stAddrData.m_nAddrLength = vecDataInfo[i].value("DATA_LENGTH").toInt();
		stAddrData.m_nOffset = vecDataInfo[i].value("OFFSET").toInt();
		if (0 == vecDataInfo[i].value("TYPE").toInt())//测点类型为读测点
		{
			pDevDataRob->m_mapAddrDataR.insert(vecDataInfo[i].value("IO_TYPE").toInt(), stAddrData);
		}
		else if (1 == vecDataInfo[i].value("TYPE").toInt())//测点类型为写测点
		{
			pDevDataRob->m_mapAddrDataW.insert(vecDataInfo[i].value("IO_TYPE").toInt(), stAddrData);
		}
	}
	return bRet;
}

QVector<CTaskInfo> selectTaskInfoEx(QString sSceneGuid, QString & sErrMsg)
{
	QVector<CTaskInfo> vecTaskInfo;
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_config";
	cData.sSql = "select * from prob_task_config where SCENE_GUID=? AND IS_DELETE=?";//根据任务类型降序排
	cData.addValue("SCENE_GUID", sSceneGuid);
	cData.addValue("IS_DELETE", "0");
	CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		CTaskInfo cTaskInfo;
		cTaskInfo.m_sTaskGuid = vecDataInfo[i].value("GUID").toString();
		cTaskInfo.m_sTaskName = vecDataInfo[i].value("TASK_NAME").toString();
		cTaskInfo.m_sGuid = sSceneGuid;
		cTaskInfo.m_sTemplateFixedID = vecDataInfo[i].value("TEMPLATE_FIXED_ID").toString();
		cTaskInfo.m_nTaskType = vecDataInfo[i].value("TASK_TYPE").toInt();
		cTaskInfo.m_sScheduledTime = vecDataInfo[i].value("SCHEDULED_TIME").toDateTime().toString("yyyy/MM/dd hh:mm:ss");
		cTaskInfo.m_nPeriodType = vecDataInfo[i].value("PERIOD_TYPE").toInt();
		cTaskInfo.m_nLatestRecord = vecDataInfo[i].value("LATEST_RECORD").toInt();
		cTaskInfo.m_sTaskActTime = cTaskInfo.m_sScheduledTime;
		vecTaskInfo.push_back(cTaskInfo);
	}
	return vecTaskInfo;
}

QMap<int, QString> selectTaskRule(QString sSceneGuid, QString & sErrMsg)
{
	QMap<int, QString>mapTaskGuid;
	CDatabaseExecData cData;
	cData.sSql = "select * from prob_task_rule where SCENE_GUID=? ";
	cData.sTableName = "prob_task_rule";
	cData.addValue("SCENE_GUID", sSceneGuid);

	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		mapTaskGuid.insert(vecDataInfo[i].value("TIME_TYPE").toInt(), vecDataInfo[i].value("TASK_GUID").toString().trimmed());
	}
	return mapTaskGuid;
}

bool selCurrTaskExecByID(const QString sSecneGuid, QVector<QSqlRecord>& vecRecord, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sSql = "select * from prob_task_exec_records where SCENE_GUID=? and DATE(START_TIME) = CURDATE()";
	cData.sTableName = "prob_task_exec_records";
	cData.addValue("SCENE_GUID", sSecneGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}



bool selTaskRuleByTimeType(QString sSceneGuid, QVector<int> vecTimeType, QVector<QSqlRecord>& vecRecord, QString sErrMsg)
{
	CDatabaseExecData cData;
	cData.sSql = "select * from prob_task_rule where SCENE_GUID=? ";
	if (vecTimeType.size() > 0)
	{
		cData.sSql += " and (";
		for (int i = 0; i < vecTimeType.size() - 1; i++)
		{
			cData.sSql += " TIME_TYPE= ";
			cData.sSql += QString::number(vecTimeType[i]);
			cData.sSql += " or ";
		}
		cData.sSql += " TIME_TYPE= ";
		cData.sSql += QString::number(vecTimeType[vecTimeType.size() - 1]);
		cData.sSql += " ) ";
	}
	cData.sTableName = "prob_task_rule";
	cData.addValue("SCENE_GUID", sSceneGuid);

	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}

QVector<CTaskInfo> selTaskInfoByTaskID(QString sSceneGuid, QVector<QString> vecTaskGuid, QString & sErrMsg)
{
	QVector<CTaskInfo> vecTaskInfo;
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_config";
	cData.sSql = "select * from prob_task_config where SCENE_GUID=? and IS_DELETE=0";
	if (vecTaskGuid.size() > 0)
	{
		cData.sSql += " and (";
		for (int i = 0; i < vecTaskGuid.size() - 1; i++)
		{
			cData.sSql += " GUID= '";
			cData.sSql += vecTaskGuid[i];
			cData.sSql += "' or ";
		}
		cData.sSql += " GUID= '";
		cData.sSql += vecTaskGuid[vecTaskGuid.size() - 1];
		cData.sSql += "' ) ";
	}
	cData.addValue("SCENE_GUID", sSceneGuid);
	CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		CTaskInfo cTaskInfo;
		cTaskInfo.m_sTaskGuid = vecDataInfo[i].value("GUID").toString();
		cTaskInfo.m_sTaskName = vecDataInfo[i].value("TASK_NAME").toString();
		cTaskInfo.m_sGuid = sSceneGuid;
		cTaskInfo.m_sTemplateFixedID = vecDataInfo[i].value("TEMPLATE_FIXED_ID").toString();
		cTaskInfo.m_nTaskType = vecDataInfo[i].value("TASK_TYPE").toInt();
		cTaskInfo.m_sScheduledTime = vecDataInfo[i].value("SCHEDULED_TIME").toDateTime().toString("yyyy/MM/dd hh:mm:ss");
		cTaskInfo.m_nPeriodType = vecDataInfo[i].value("PERIOD_TYPE").toInt();
		cTaskInfo.m_nLatestRecord = vecDataInfo[i].value("LATEST_RECORD").toInt();
		//wxy++20240506
		cTaskInfo.m_nContIrTemp = vecDataInfo[i].value("CONT_IR_TEMP").toInt();
		cTaskInfo.m_nContSoundDet = vecDataInfo[i].value("CONT_SOUND_DET").toInt();

		vecTaskInfo.push_back(cTaskInfo);
	}
	return vecTaskInfo;
}

bool selectPloItemCamerBySceneID(const QString sSceneGuid, QVector<QSqlRecord>& vecRecord, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_item_config_pan";
	cData.sSql = "select * from prob_poll_item_config_pan where SCENE_GUID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("SCENE_GUID");
	cData.vecValue.push_back(sSceneGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}

bool selectPloItemSensorBySceneID(const QString sSceneGuid, QVector<QSqlRecord>& vecRecord, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_item_config_sensor";
	cData.sSql = "select * from prob_poll_item_config_sensor where SCENE_GUID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("SCENE_GUID");
	cData.vecValue.push_back(sSceneGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}

bool selectImageItemExecCotdet(const QString sTaskExecGuid, int nItemTypeCode, QVector<QSqlRecord>& vecRecord, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sSql = "select * from prob_image_item_exec_records where TASK_EXEC_GUID=? and ITEM_TYPE_CODE=? and IS_COTDET=1 order by ROLLER_NO asc";
	cData.sTableName = "prob_image_item_exec_records";
	cData.addValue("TASK_EXEC_GUID", sTaskExecGuid);
	cData.addValue("ITEM_TYPE_CODE", nItemTypeCode);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}

bool selectSensorItemExecByTaskExecID(const QString sSecneGuid, QString sTaskExecGuid, QVector<QSqlRecord>& vecRecord, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sSql = "select * from prob_sensor_item_exec_records where SCENE_GUID=? and TASK_EXEC_GUID=?";
	cData.sTableName = "prob_sensor_item_exec_records";
	cData.addValue("SCENE_GUID", sSecneGuid);
	cData.addValue("TASK_EXEC_GUID", sTaskExecGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}

bool selectImageItemExecByTaskExecID(const QString sSecneGuid, QString sTaskExecGuid, QVector<QSqlRecord>& vecRecord, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sSql = "select * from prob_image_item_exec_records where SCENE_GUID=? and TASK_EXEC_GUID=? ";
	cData.sTableName = "prob_image_item_exec_records";
	cData.addValue("SCENE_GUID", sSecneGuid);
	cData.addValue("TASK_EXEC_GUID", sTaskExecGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}

bool selectTaskExec(const CTaskExecInfo info, QVector<QSqlRecord>& vecRecord, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sSql = QString("select * from prob_task_exec_records where SCENE_GUID='%1' and START_TIME >= str_to_date('%2','%Y/%m/%d %T') and START_TIME <= str_to_date('%3','%Y/%m/%d %T') order by START_TIME desc")
		.arg(info.m_sGuid)
		.arg(info.m_sStartTime)
		.arg(info.m_sEndTime);
	cData.sTableName = "prob_task_exec_records";
	if (info.m_sTaskGuid != "")
	{
		cData.sSql += QString("and TASK_GUID = '%1'")
			.arg(info.m_sTaskGuid);
	}
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}

bool selAreaByGuid(const QString sSceneGuid, CPolArea * pPolArea, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_area_config";
	cData.sSql = "select * from prob_poll_area_config where SCENE_GUID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("SCENE_GUID");
	cData.vecValue.push_back(sSceneGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		pPolArea->m_sPolAreaGuid = vecDataInfo[i].value("GUID").toString();
		pPolArea->m_sPolAreaName = vecDataInfo[i].value("AREA_NAME").toString();
		pPolArea->m_sGuid = sSceneGuid;
		pPolArea->m_nChargeNum = vecDataInfo[i].value("CHARGE_NUMBER").toInt();
		pPolArea->m_sChargeXY = vecDataInfo[i].value("CHARGE_XY").toString();
	}
	return bRet;
}

bool selPointByGuiD(const QString sSceneGuid, QMap<QString, CPolPoint*>& mapPolPoint, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_point_config";
	cData.sSql = "select * from prob_poll_point_config where SCENE_GUID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("SCENE_GUID");
	cData.vecValue.push_back(sSceneGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		CPolPoint* pPolPoint = new CPolPoint();
		pPolPoint->m_sPointGuid = vecDataInfo[i].value("GUID").toString();
		pPolPoint->m_sPointName = vecDataInfo[i].value("POLL_POINT_NAME").toString();
		pPolPoint->m_sPolAreaGuid = vecDataInfo[i].value("POLL_AREA_GUID").toString();
		pPolPoint->m_sGuid = sSceneGuid;
		pPolPoint->m_dPointLocation = vecDataInfo[i].value("POINT_LOCATION").toDouble();
		pPolPoint->m_dPointX = vecDataInfo[i].value("POINT_X").toDouble();
		pPolPoint->m_dPointY = vecDataInfo[i].value("POINT_Y").toDouble();
		pPolPoint->m_dPointZ = vecDataInfo[i].value("POINT_Z").toDouble();
		pPolPoint->m_nIsChargePoint = vecDataInfo[i].value("IS_CHARGING_POINT").toInt();
		mapPolPoint.insert(vecDataInfo[i].value("GUID").toString(), pPolPoint);
	}
	return bRet;
}

bool selItemCamerByGuid(const QString sSceneGuid, QMap<QString, CPolPoint*>& mapPolPoint, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_item_config_pan";
	cData.sSql = "select * from prob_poll_item_config_pan where SCENE_GUID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("SCENE_GUID");
	cData.vecValue.push_back(sSceneGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		CPolItemCamer* pPolItemCamer = new CPolItemCamer();
		pPolItemCamer->m_sItemGuid = vecDataInfo[i].value("GUID").toString();
		pPolItemCamer->m_sItemName = vecDataInfo[i].value("POLL_ITEM_NAME").toString();
		pPolItemCamer->m_sGuid = sSceneGuid;
		pPolItemCamer->m_nDevType = vecDataInfo[i].value("DEVICE_TYPE").toInt();
		pPolItemCamer->m_nDevTypeCode = vecDataInfo[i].value("ITEM_DEVICE_TYPE_CODE").toInt();
		pPolItemCamer->m_sPointGuid = vecDataInfo[i].value("POLL_POINT_GUID").toString();
		pPolItemCamer->m_sDataThreadHoldHH = vecDataInfo[i].value("DATA_THRESHOLD_HH").toString();
		pPolItemCamer->m_sDataThreadHoldH = vecDataInfo[i].value("DATA_THRESHOLD_H").toString();
		pPolItemCamer->m_sDataThreadHoldLL = vecDataInfo[i].value("DATA_THRESHOLD_LL").toString();
		pPolItemCamer->m_sDataThreadHoldL = vecDataInfo[i].value("DATA_THRESHOLD_L").toString();
		pPolItemCamer->m_nCheckType = vecDataInfo[i].value("CHECK_TYPE").toInt();
		pPolItemCamer->m_nCollectIndex = vecDataInfo[i].value("COLLECT_INDEX").toInt();
		pPolItemCamer->m_nTackPicture = vecDataInfo[i].value("TACK_PICTURE").toInt();
		pPolItemCamer->m_nDataType = vecDataInfo[i].value("DATA_TYPE").toInt();
		pPolItemCamer->m_nAlarmLevel = vecDataInfo[i].value("ALARM_LEVEL").toInt();
		pPolItemCamer->m_dItemZ = vecDataInfo[i].value("ITEMZ").toDouble();//巡检项坐标Z(现在是cm)
		pPolItemCamer->m_dAngelIR = vecDataInfo[i].value("RANGEL").toDouble();
		pPolItemCamer->m_dAngelCamer = vecDataInfo[i].value("ANGEL_CAMER").toDouble();
		pPolItemCamer->m_dCollectTime = vecDataInfo[i].value("COLLECT_TIME").toDouble();
		pPolItemCamer->m_nIndex = vecDataInfo[i].value("ITEM_INDEX").toDouble();
		pPolItemCamer->m_dCollectInterval = vecDataInfo[i].value("COLLECT_INTERVAL").toDouble();
		pPolItemCamer->m_nBelong = vecDataInfo[i].value("BELONG").toInt();
		pPolItemCamer->m_nCollectCheckType = vecDataInfo[i].value("COLLECT_CHECK_TYPE").toInt();
		pPolItemCamer->m_nCollectRollerNum = vecDataInfo[i].value("COLLECT_ROLLER_NUM").toInt();
		pPolItemCamer->m_dRollerOffdetDis = vecDataInfo[i].value("ROLLER_OFFSET_DIS").toDouble();
		pPolItemCamer->m_nIsExecAI = vecDataInfo[i].value("IS_EXEC_AI").toInt();
		//判断是否存在这个巡检点GUID的巡检点
		if (mapPolPoint.contains(vecDataInfo[i].value("POLL_POINT_GUID").toString()))
		{
			mapPolPoint[vecDataInfo[i].value("POLL_POINT_GUID").toString()]->m_mapPolItem.insert(pPolItemCamer->m_sItemGuid, pPolItemCamer);
		}
	}
	return bRet;
}

bool selItemSensorByGuid(const QString sSceneGuid, QMap<QString, CPolPoint*>& mapPolPoint, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_item_config_sensor";
	cData.sSql = "select * from prob_poll_item_config_sensor where SCENE_GUID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("SCENE_GUID");
	cData.vecValue.push_back(sSceneGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		CPolItemSensor* pPolItemSensor = new CPolItemSensor();
		pPolItemSensor->m_sItemGuid = vecDataInfo[i].value("GUID").toString();
		pPolItemSensor->m_sItemName = vecDataInfo[i].value("POLL_ITEM_NAME").toString();
		pPolItemSensor->m_sGuid = sSceneGuid;
		pPolItemSensor->m_sPointGuid = vecDataInfo[i].value("POLL_POINT_GUID").toString();
		pPolItemSensor->m_nDevType = vecDataInfo[i].value("DEVICE_TYPE").toInt();
		pPolItemSensor->m_nDevTypeCode = vecDataInfo[i].value("ITEM_DEVICE_TYPE_CODE").toInt();
		pPolItemSensor->m_nAlarmLevel = vecDataInfo[i].value("ALARM_LEVEL").toInt();
		pPolItemSensor->m_sDataThreadHoldHH = vecDataInfo[i].value("DATA_THRESHOLD_HH").toString();
		pPolItemSensor->m_sDataThreadHoldH = vecDataInfo[i].value("DATA_THRESHOLD_H").toString();
		pPolItemSensor->m_sDataThreadHoldLL = vecDataInfo[i].value("DATA_THRESHOLD_LL").toString();
		pPolItemSensor->m_sDataThreadHoldL = vecDataInfo[i].value("DATA_THRESHOLD_L").toString();
		pPolItemSensor->m_nIndex = vecDataInfo[i].value("ITEM_INDEX").toInt();
		pPolItemSensor->m_nBelong = vecDataInfo[i].value("BELONG").toInt();
		pPolItemSensor->m_nCheckType = vecDataInfo[i].value("CHECK_TYPE").toInt();
		pPolItemSensor->m_nCollectIndex = vecDataInfo[i].value("COLLECT_INDEX").toInt();
		pPolItemSensor->m_nCollectCheckType = vecDataInfo[i].value("COLLECT_CHECK_TYPE").toInt();
		pPolItemSensor->m_nCollectRollerNum = vecDataInfo[i].value("COLLECT_ROLLER_NUM").toInt();
		pPolItemSensor->m_dCollectInterval = vecDataInfo[i].value("COLLECT_INTERVAL").toDouble();
		//判断是否存在这个巡检点GUID的巡检点
		if (mapPolPoint.contains(vecDataInfo[i].value("POLL_POINT_GUID").toString()))
		{
			mapPolPoint[vecDataInfo[i].value("POLL_POINT_GUID").toString()]->m_mapPolItem.insert(pPolItemSensor->m_sItemGuid, pPolItemSensor);
		}
	}
	return bRet;
}

bool insertTaskExecInfoEx(CTaskInfo cTaskInof)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_exec_records";
	cData.sSql = "INSERT INTO prob_task_exec_records (GUID,TASK_GUID,TASK_NAME,SCENE_GUID,EXEC_STATUS,START_TIME)"
		"values(?,?,?,?,?,?)";
	cData.addValue("GUID", createGuid());
	cData.addValue("TASK_GUID", cTaskInof.m_sTaskGuid);
	cData.addValue("TASK_NAME", cTaskInof.m_sTaskName);
	cData.addValue("SCENE_GUID", cTaskInof.m_sGuid);
	cData.addValue("EXEC_STATUS", "4");
	cData.addValue("START_TIME", cTaskInof.m_sTaskActTime);
	return CPublicData::instance().m_pSqlDllOper->exec(cData);
}

bool selectAllTaskInfo(const QString sSceneGuid, QVector<QSqlRecord>& vecRecord, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sSql = "select * from prob_task_config where SCENE_GUID=? and IS_DELETE=0";
	cData.sTableName = "prob_task_config";
	cData.addValue("SCENE_GUID", sSceneGuid);

	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}

bool selectPerTaskInfo(const QString sSceneGuid, QVector<QSqlRecord>& vecRecord, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_rule,prob_task_config";
	cData.sSql = "select a.TIME_TYPE,a.TASK_GUID,a.SCENE_GUID,b.TASK_NAME,b.TEMPLATE_FIXED_ID,b.TASK_TYPE,b.SCHEDULED_TIME,b.PERIOD_TYPE,b.LATEST_RECORD,b.CREATE_TIME "
		"from prob_task_rule as a "
		"left join prob_task_config as b on a.TASK_GUID = b.GUID "
		"where a.SCENE_GUID='" + sSceneGuid + "' and a.TASK_GUID !='' and b.IS_DELETE = 0";

	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}

bool selectTaskExecByDate(const QString sTaskGuid, const QString sStartDate, QVector<CTaskExecInfo>& vecTaskExec, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_exec_records";
	cData.sSql = QString("select * from prob_task_exec_records where TASK_GUID='%1' and DATE_FORMAT(START_TIME, '%Y/%m/%d') = '%2'")
		.arg(sTaskGuid)
		.arg(sStartDate);
	cData.vecField.clear();
	cData.vecValue.clear();
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		CTaskExecInfo uTaskExec;
		uTaskExec.m_sTaskExecGuid = vecDataInfo[i].value("GUID").toString();
		uTaskExec.m_sTaskName = vecDataInfo[i].value("TASK_NAME").toString();
		uTaskExec.m_sTemplateGuid = vecDataInfo[i].value("TEMPLATE_GUID").toString();
		uTaskExec.m_nExecState = vecDataInfo[i].value("EXEC_STATUS").toInt();
		uTaskExec.m_nItemCount = vecDataInfo[i].value("ITEM_COUNT").toInt();
		uTaskExec.m_nExecItemCount = vecDataInfo[i].value("EXEC_ITEM_COUNT").toInt();
		uTaskExec.m_nAlarmItemCount = vecDataInfo[i].value("ALARM_ITEM_COUNT").toInt();
		uTaskExec.m_nCollectAlarmCount = vecDataInfo[i].value("COLLECT_ALARM_COUNT").toInt();
		uTaskExec.m_sStartTime = vecDataInfo[i].value("START_TIME").toDateTime().toString("yyyy/MM/dd hh:mm:ss");
		uTaskExec.m_sEndTime = vecDataInfo[i].value("END_TIME").toDateTime().toString("yyyy/MM/dd hh:mm:ss");
		uTaskExec.m_dStartPower = vecDataInfo[i].value("START_POWER").toDouble();
		uTaskExec.m_dEndPower = vecDataInfo[i].value("END_POWER").toDouble();
		vecTaskExec.push_back(uTaskExec);
	}
	return bRet;
}

bool selectTaskExecByDateTime(const QString sTaskGuid, const QString sStartDateTime, CTaskExecInfo & uTaskExec, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_exec_records";
	cData.sSql = QString("select * from prob_task_exec_records where TASK_GUID='%1' and START_TIME >= DATE_SUB(STR_TO_DATE('%2', '%Y/%m/%d %H:%i:%s'), INTERVAL 1 MINUTE)"
		"AND START_TIME <= DATE_ADD(STR_TO_DATE('%2', '%Y/%m/%d %H:%i:%s'), INTERVAL 1 MINUTE)")
		.arg(sTaskGuid)
		.arg(sStartDateTime);
	cData.vecField.clear();
	cData.vecValue.clear();
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		uTaskExec.m_sTaskExecGuid = vecDataInfo[i].value("GUID").toString();
		uTaskExec.m_sTaskName = vecDataInfo[i].value("TASK_NAME").toString();
		uTaskExec.m_sTemplateGuid = vecDataInfo[i].value("TEMPLATE_GUID").toString();
		uTaskExec.m_nExecState = vecDataInfo[i].value("EXEC_STATUS").toInt();
		uTaskExec.m_nItemCount = vecDataInfo[i].value("ITEM_COUNT").toInt();
		uTaskExec.m_nExecItemCount = vecDataInfo[i].value("EXEC_ITEM_COUNT").toInt();
		uTaskExec.m_nAlarmItemCount = vecDataInfo[i].value("ALARM_ITEM_COUNT").toInt();
		uTaskExec.m_nCollectAlarmCount = vecDataInfo[i].value("COLLECT_ALARM_COUNT").toInt();
		uTaskExec.m_sStartTime = vecDataInfo[i].value("START_TIME").toDateTime().toString("yyyy/MM/dd hh:mm:ss");
		uTaskExec.m_sEndTime = vecDataInfo[i].value("END_TIME").toDateTime().toString("yyyy/MM/dd hh:mm:ss");
		uTaskExec.m_dStartPower = vecDataInfo[i].value("START_POWER").toDouble();
		uTaskExec.m_dEndPower = vecDataInfo[i].value("END_POWER").toDouble();
	}
	return bRet;
}

bool selectTaskRule(QString sSceneGuid, QVector<QSqlRecord>& vecRecord, QString sErrMsg)
{
	CDatabaseExecData cData;
	cData.sSql = "select * from prob_task_rule where SCENE_GUID=? ";
	cData.sTableName = "prob_task_rule";
	cData.addValue("SCENE_GUID", sSceneGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}

QVector<CTaskInfo> selectTaskInfoCycTask(QString sSceneGuid, QString & sErrMsg)
{
	QVector<CTaskInfo> vecTaskInfo;
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_config";
	cData.sSql = "select * from prob_task_config where SCENE_GUID=? and TASK_TYPE=1";//查询所有周期性任务
	cData.addValue("SCENE_GUID", sSceneGuid);
	CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		CTaskInfo cTaskInfo;
		cTaskInfo.m_sTaskGuid = vecDataInfo[i].value("GUID").toString();
		cTaskInfo.m_sTaskName = vecDataInfo[i].value("TASK_NAME").toString();
		cTaskInfo.m_sGuid = sSceneGuid;
		cTaskInfo.m_sTemplateFixedID = vecDataInfo[i].value("TEMPLATE_FIXED_ID").toString();
		cTaskInfo.m_nTaskType = vecDataInfo[i].value("TASK_TYPE").toInt();
		cTaskInfo.m_sScheduledTime = vecDataInfo[i].value("SCHEDULED_TIME").toDateTime().toString("yyyy/MM/dd hh:mm:ss");
		cTaskInfo.m_nPeriodType = vecDataInfo[i].value("PERIOD_TYPE").toInt();
		cTaskInfo.m_nLatestRecord = vecDataInfo[i].value("LATEST_RECORD").toInt();
		vecTaskInfo.push_back(cTaskInfo);
	}
	return vecTaskInfo;
}

bool updateTaskRule(QString sSceneGuid, QVector<int> vecTimeType, QString sNewTaskguid, QString sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_rule";
	cData.sSql = "update prob_task_rule set TASK_GUID='" + sNewTaskguid + "' where SCENE_GUID='" + sSceneGuid + "'";
	if (vecTimeType.size() > 0)
	{
		cData.sSql += " and (";
		for (int i = 0; i < vecTimeType.size() - 1; i++)
		{
			cData.sSql += " TIME_TYPE= ";
			cData.sSql += QString::number(vecTimeType[i]);
			cData.sSql += " or ";
		}
		cData.sSql += " TIME_TYPE= ";
		cData.sSql += QString::number(vecTimeType[vecTimeType.size() - 1]);
		cData.sSql += " ) ";
	}

	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool addTaskInfo(CTaskInfo & taskInfo, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_config";
	cData.sSql = "insert into prob_task_config (GUID,TASK_NAME,SCENE_GUID,TEMPLATE_FIXED_ID,TASK_TYPE,SCHEDULED_TIME,PERIOD_TYPE,LATEST_RECORD,CREATE_TIME,CONT_IR_TEMP,CONT_SOUND_DET)"
		" values(?,?,?,?,?,?,?,?,?,?,?)";
	cData.addValue("GUID", taskInfo.m_sTaskGuid);
	cData.addValue("TASK_NAME", taskInfo.m_sTaskName);
	cData.addValue("SCENE_GUID", taskInfo.m_sGuid);
	cData.addValue("TEMPLATE_FIXED_ID", taskInfo.m_sTemplateFixedID);
	cData.addValue("TASK_TYPE", taskInfo.m_nTaskType);
	cData.addValue("SCHEDULED_TIME", taskInfo.m_sScheduledTime);
	cData.addValue("PERIOD_TYPE", taskInfo.m_nPeriodType);
	cData.addValue("LATEST_RECORD", taskInfo.m_nLatestRecord);
	cData.addValue("CREATE_TIME", QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss"));
	cData.addValue("CONT_IR_TEMP", taskInfo.m_nContIrTemp);//wxy++20240430
	cData.addValue("CONT_SOUND_DET", taskInfo.m_nContSoundDet);//wxy++20240430
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool updateTaskInfo(CTaskInfo& taskInfo, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_config";
	cData.sSql = "update prob_task_config set TASK_NAME=?,SCENE_GUID=?,TEMPLATE_FIXED_ID=?,TASK_TYPE=?,SCHEDULED_TIME=?,PERIOD_TYPE=?,LATEST_RECORD=?,CONT_IR_TEMP=?,CONT_SOUND_DET=?"
		" where GUID=?";
	cData.addValue("TASK_NAME", taskInfo.m_sTaskName);
	cData.addValue("SCENE_GUID", taskInfo.m_sGuid);
	cData.addValue("TEMPLATE_FIXED_ID", taskInfo.m_sTemplateFixedID);
	cData.addValue("TASK_TYPE", taskInfo.m_nTaskType);
	cData.addValue("SCHEDULED_TIME", QDateTime::fromString(taskInfo.m_sScheduledTime, "yyyy/MM/dd hh:mm:ss"));
	cData.addValue("PERIOD_TYPE", taskInfo.m_nPeriodType);
	cData.addValue("LATEST_RECORD", taskInfo.m_nLatestRecord);
	cData.addValue("CONT_IR_TEMP", taskInfo.m_nContIrTemp);//wxy++20240430
	cData.addValue("CONT_SOUND_DET", taskInfo.m_nContSoundDet);//wxy++20240430
	cData.addValue("GUID", taskInfo.m_sTaskGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}
bool selectTaskInfo(const CTaskInfo taskInfo, QVector<QSqlRecord>& vecRecord, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sSql = "select * from prob_task_config where SCENE_GUID=? and IS_DELETE=0 ";
	cData.sTableName = "prob_task_config";
	cData.addValue("SCENE_GUID", taskInfo.m_sGuid);
	if (taskInfo.m_nTaskType != -1)
	{
		cData.sSql += "and TASK_TYPE = ? ";
		cData.addValue("TASK_TYPE", taskInfo.m_nTaskType);
	}
	if (taskInfo.m_nPeriodType != -1)
	{
		cData.sSql += "and PERIOD_TYPE = ? ";
		cData.addValue("PERIOD_TYPE", taskInfo.m_nPeriodType);
	}
	if (taskInfo.m_sTemplateFixedID != "")
	{
		cData.sSql += "and TEMPLATE_FIXED_ID = ? ";
		cData.addValue("TEMPLATE_FIXED_ID", taskInfo.m_sTemplateFixedID);
	}

	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}
bool deleteTaskRule(QString sSceneGuid, QString sTaskguid, QString sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_rule";
	cData.sSql = "update prob_task_rule set TASK_GUID='' where SCENE_GUID=? and TASK_GUID='" + sTaskguid + "'";
	cData.addValue("SCENE_GUID", sSceneGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}
bool deleteTaskInfoByTaskID(QString sTaskGuid, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_config";
	cData.sSql = "update prob_task_config set IS_DELETE=1 where GUID=?";
	cData.addValue("GUID", sTaskGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}
bool updateTaskExecInfo(CTaskExecInfo * pTaskExecInfo)
{
	bool bResult = false;
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_exec_records";
	cData.sSql = "UPDATE prob_task_exec_records SET TASK_NAME=?,TEMPLATE_GUID=?,SCENE_GUID=?,EXEC_STATUS=?,ITEM_COUNT=?,EXEC_ITEM_COUNT=?,ALARM_ITEM_COUNT=?,START_TIME=?,END_TIME=?,START_POWER=?,END_POWER=?,PDF_PATH=?,PDF_PATH_URL=?,TASK_ERR_DSC=?,TASK_EXEC_DSC=?"
		" WHERE GUID=?";
	cData.addValue("TASK_NAME", pTaskExecInfo->m_sTaskName);//任务名称
	cData.addValue("TEMPLATE_GUID", pTaskExecInfo->m_sTemplateGuid);//模板GUID
	cData.addValue("SCENE_GUID", pTaskExecInfo->m_sGuid);//归属场景GUID
	cData.addValue("EXEC_STATUS", pTaskExecInfo->m_nExecState);//任务执行状态 0 未执行  1 已执行  2执行中  3任务中止
	cData.addValue("ITEM_COUNT", pTaskExecInfo->m_nItemCount);//巡检项数量
	cData.addValue("EXEC_ITEM_COUNT", pTaskExecInfo->m_nExecItemCount);//已执行巡检项数量
	cData.addValue("ALARM_ITEM_COUNT", pTaskExecInfo->m_nAlarmItemCount);//报警巡检项数量
	cData.addValue("START_TIME", pTaskExecInfo->m_sStartTime);//开始时间
	cData.addValue("END_TIME", pTaskExecInfo->m_sEndTime);//结束时间
	cData.addValue("START_POWER", pTaskExecInfo->m_dStartPower);//开始电量
	cData.addValue("END_POWER", pTaskExecInfo->m_dEndPower);//结束电量
	cData.addValue("PDF_PATH", pTaskExecInfo->m_sPdfPath);//生成的Pdf路径
	cData.addValue("PDF_PATH_URL", pTaskExecInfo->m_sPdfPathUrl);//生成的Pdf路径
	cData.addValue("TASK_ERR_DSC", pTaskExecInfo->m_sTaskBreakReason);//任务执行异常描述
	cData.addValue("TASK_EXEC_DSC", pTaskExecInfo->m_sTaskExecDes);//任务执行结果描述
	cData.addValue("GUID", pTaskExecInfo->m_sTaskExecGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	return bResult;
}
bool insertItemExecResult(CTaskExecInfo * pTaskExecInfo)
{
	if (pTaskExecInfo == nullptr)
	{
		return false;
	}

	for (int i = 0; i < pTaskExecInfo->m_vecPolItemCom.size(); i++)
	{
		SCPolItemCom *pPolItemCom = pTaskExecInfo->m_vecPolItemCom[i];
		if (pPolItemCom == nullptr)
		{
			continue;
		}

		if (pPolItemCom->m_bIsAction && (!pPolItemCom->m_bIsSave))//已执行 并且 未保存到数据库
		{
			if (pPolItemCom->m_ItemResult->m_nDevType == 0)//0 本体(传感器)
			{
				if (!pPolItemCom->m_bIsSave)
				{
					insertSensorItemResult((CItemResultSensor *)pPolItemCom->m_ItemResult);//更新传感器结果数据到数据库
					pPolItemCom->m_bIsSave = true;
				}
			}
			else if (pPolItemCom->m_ItemResult->m_nDevType == 1)//1云台
			{
				if (!pPolItemCom->m_bIsSave)
				{
					insertCamerItemResult((CItemResultCamera *)pPolItemCom->m_ItemResult);//更新云台结果数据到数据库
					if (pPolItemCom->m_pPolItem->m_nDevTypeCode == enIR)
					{
						//更新报警通知表
						//updateAlmInform(pPolItemCom->m_pPolItem->m_sGuid, enIR);
					}
					pPolItemCom->m_bIsSave = true;
				}
			}
		}

	}

	return true;
}
bool insertSensorItemResult(CItemResultSensor * pItemResultSensor)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_sensor_item_exec_records";

	cData.sSql = "INSERT INTO prob_sensor_item_exec_records (GUID,SCENE_GUID,POINT_GUID,ITEM_GUID,TASK_EXEC_GUID,TEMPLATE_GUID,START_TIME,ALARM_LEVEL,ITEM_TYPE_CODE,SENSOR_DATA,SENSOR_DATA_DESC,DATA_THRESHOLD_HH,DATA_THRESHOLD_H,DATA_THRESHOLD_LL,DATA_THRESHOLD_L,IS_CONFIRM,IS_BROADCAST,ROLLER_CODE,ROLLER_NO,BELONG)"
		"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

	cData.addValue("GUID", pItemResultSensor->m_sItemResultGuid);//巡检项结果Guid
	cData.addValue("SCENE_GUID", pItemResultSensor->m_sGuid);//场景Guid
	cData.addValue("POINT_GUID", pItemResultSensor->m_sPointGuid);//巡检点GUID
	cData.addValue("ITEM_GUID", pItemResultSensor->m_sItemGuid);//巡检项GUID
	cData.addValue("TASK_EXEC_GUID", pItemResultSensor->m_sTaskExecGuid);//任务执行记录GUID
	cData.addValue("TEMPLATE_GUID", pItemResultSensor->m_sTemplateGuid);//模板GUID
	cData.addValue("START_TIME", pItemResultSensor->m_dActionTime);//执行时间
	cData.addValue("ALARM_LEVEL", pItemResultSensor->m_nAlarmLevel);//报警等级
	cData.addValue("ITEM_TYPE_CODE", pItemResultSensor->m_nDevTypeCode);//巡检项设备类型编码  0图像相机 1红外相机 2声音传感器 3一氧化碳  4.可燃气体 5.PM25 6.PM10 7.温度 8.湿度
	cData.addValue("SENSOR_DATA", pItemResultSensor->m_dValue);//传感器检测结果数值
	cData.addValue("SENSOR_DATA_DESC", pItemResultSensor->m_sDataDesc);//传感器报警描述
	cData.addValue("DATA_THRESHOLD_HH", pItemResultSensor->m_sDataThreadHoldHH);//数据阈值-高高报
	cData.addValue("DATA_THRESHOLD_H", pItemResultSensor->m_sDataThreadHoldH);//数据阈值-高报
	cData.addValue("DATA_THRESHOLD_LL", pItemResultSensor->m_sDataThreadHoldLL);//数据阈值-低低报
	cData.addValue("DATA_THRESHOLD_L", pItemResultSensor->m_sDataThreadHoldL);//数据阈值-低报

	//wxy++
	cData.addValue("IS_CONFIRM", 0);//是否已确认
	cData.addValue("IS_BROADCAST", 0);//是否已播报
	cData.addValue("ROLLER_CODE", pItemResultSensor->m_sRollerDesc);//托辊号描述
	cData.addValue("ROLLER_NO", pItemResultSensor->m_nRollerNum);//托辊号
	cData.addValue("BELONG", pItemResultSensor->m_nBelong);//归属皮带

	return CPublicData::instance().m_pSqlDllOper->exec(cData);
}
bool insertCamerItemResult(CItemResultCamera * pItemResultCamera)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_image_item_exec_records";

	cData.sSql = "INSERT INTO prob_image_item_exec_records (GUID,SCENE_GUID,POINT_GUID,ITEM_GUID,TASK_EXEC_GUID,TEMPLATE_GUID,START_TIME,ALARM_LEVEL,ITEM_TYPE_CODE,IR_ALM_DESC,DATA_THRESHOLD_HH,DATA_THRESHOLD_H,DATA_THRESHOLD_LL,DATA_THRESHOLD_L,IR_URL,IR_RESULT_URL,RESULT_HTTP_URL,TEMP_MAX,TEMP_MIN,TEMP_AGV,IS_COTDET,COTDET_LOC,COTDET_ROLLER_CODE,VOICE_DATA,VOICE_DATA_STR,IS_CONFIRM,IS_BROADCAST,ROLLER_CODE,ROLLER_NO,BELONG)"
		"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

	cData.addValue("GUID", pItemResultCamera->m_sItemResultGuid);//巡检项结果Guid
	cData.addValue("SCENE_GUID", pItemResultCamera->m_sGuid);//场景Guid
	cData.addValue("POINT_GUID", pItemResultCamera->m_sPointGuid);//巡检点GUID
	cData.addValue("ITEM_GUID", pItemResultCamera->m_sItemGuid);//巡检项GUID
	cData.addValue("TASK_EXEC_GUID", pItemResultCamera->m_sTaskExecGuid);//任务执行记录GUID
	cData.addValue("TEMPLATE_GUID", pItemResultCamera->m_sTemplateGuid);//模板GUID
	cData.addValue("START_TIME", pItemResultCamera->m_dActionTime);//执行时间
	cData.addValue("ALARM_LEVEL", pItemResultCamera->m_nAlarmLevel);//报警等级
	cData.addValue("ITEM_TYPE_CODE", pItemResultCamera->m_nDevTypeCode);//巡检项设备类型编码  0图像相机 1红外相机 2声音传感器 3一氧化碳  4.可燃气体 5.PM25 6.PM10 7.温度 8.湿度
	cData.addValue("IR_ALM_DESC", pItemResultCamera->m_sDataDesc);//传感器报警描述
	cData.addValue("DATA_THRESHOLD_HH", pItemResultCamera->m_sDataThreadHoldHH);//数据阈值-高高报
	cData.addValue("DATA_THRESHOLD_H", pItemResultCamera->m_sDataThreadHoldH);//数据阈值-高报
	cData.addValue("DATA_THRESHOLD_LL", pItemResultCamera->m_sDataThreadHoldLL);//数据阈值-低低报
	cData.addValue("DATA_THRESHOLD_L", pItemResultCamera->m_sDataThreadHoldL);//数据阈值-低报
	cData.addValue("IR_URL", pItemResultCamera->m_sIRUrl);//原始红外相机图片地址
	cData.addValue("IR_RESULT_URL", pItemResultCamera->m_sAlarmUrl);//报警图地址
	cData.addValue("RESULT_HTTP_URL", pItemResultCamera->m_sHttpUrl);//结果图片网络地址
	cData.addValue("TEMP_MAX", pItemResultCamera->m_dTempMax);//最高温度
	cData.addValue("TEMP_MIN", pItemResultCamera->m_dTempMin);//最低温度
	cData.addValue("TEMP_AGV", pItemResultCamera->m_dTempAverage);//平均温度

	//wxy++
	cData.addValue("IS_COTDET", pItemResultCamera->m_nCheckType ? 1 : 0);//是否是连续检测结果
	cData.addValue("COTDET_LOC", QString::number(pItemResultCamera->m_dRealLocation, 'f', 2));//连续检测结果的当前所在位置m
	cData.addValue("COTDET_ROLLER_CODE", pItemResultCamera->m_sRollerDesc);//连续检测结果的当前所在托辊号
	cData.addValue("VOICE_DATA", QString::number(pItemResultCamera->m_dValue, 'f', 2));//声音测量值
	cData.addValue("VOICE_DATA_STR", pItemResultCamera->m_sDataDesc);//声音检测报警描述
	cData.addValue("IS_CONFIRM", 0);//是否已确认
	cData.addValue("IS_BROADCAST", 0);//是否已播报
	cData.addValue("ROLLER_CODE", pItemResultCamera->m_sRollerDesc);//托辊号描述
	cData.addValue("ROLLER_NO", pItemResultCamera->m_nRollerNum);//托辊号
	cData.addValue("BELONG", pItemResultCamera->m_nBelong);//归属皮带

	return CPublicData::instance().m_pSqlDllOper->exec(cData);
}
bool insertTaskExecInfo(CTaskExecInfo * pTaskExecInfo)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_exec_records";
	cData.sSql = "INSERT INTO prob_task_exec_records (GUID,TASK_GUID,TASK_NAME,TEMPLATE_GUID,SCENE_GUID,EXEC_STATUS,ITEM_COUNT,EXEC_ITEM_COUNT,ALARM_ITEM_COUNT,START_TIME,END_TIME,START_POWER,END_POWER)"
		"values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
	cData.addValue("GUID", pTaskExecInfo->m_sTaskExecGuid);
	cData.addValue("TASK_GUID", pTaskExecInfo->m_sTaskGuid);
	cData.addValue("TASK_NAME", pTaskExecInfo->m_sTaskName);
	cData.addValue("TEMPLATE_GUID", pTaskExecInfo->m_sTemplateGuid);
	cData.addValue("SCENE_GUID", pTaskExecInfo->m_sGuid);
	cData.addValue("EXEC_STATUS", pTaskExecInfo->m_nExecState);
	cData.addValue("ITEM_COUNT", pTaskExecInfo->m_nItemCount);
	cData.addValue("EXEC_ITEM_COUNT", pTaskExecInfo->m_nExecItemCount);
	cData.addValue("ALARM_ITEM_COUNT", pTaskExecInfo->m_nAlarmItemCount);
	cData.addValue("START_TIME", pTaskExecInfo->m_sStartTime);
	cData.addValue("END_TIME", pTaskExecInfo->m_sEndTime);
	cData.addValue("START_POWER", pTaskExecInfo->m_dStartPower);
	cData.addValue("END_POWER", pTaskExecInfo->m_dEndPower);
	return CPublicData::instance().m_pSqlDllOper->exec(cData);
}
bool updateCollectCount(CItemResultCamera * pItemResultCamera)
{
	return false;
}
bool updateCollectCountEx(QString sGuid, int nAlarmCount, int nExecCount)
{
	bool bResult = false;
	CDatabaseExecData cData;
	cData.sTableName = "prob_task_exec_records";
	cData.sSql = "UPDATE prob_task_exec_records SET COLLECT_ALARM_COUNT=?,COLLECT_COUNT=?"
		" WHERE GUID=?";
	cData.addValue("COLLECT_ALARM_COUNT", QString::number(nAlarmCount));
	cData.addValue("COLLECT_COUNT", QString::number(nExecCount));
	cData.addValue("GUID", sGuid);
	bResult = CPublicData::instance().m_pSqlDllOper->exec(cData);
	return bResult;
}
bool selectSensorItemExecByItemExecID(const QString sItemExecGuid, QVector<QSqlRecord>& vecRecord, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sSql = "select * from prob_sensor_item_exec_records where GUID=?";
	cData.sTableName = "prob_sensor_item_exec_records";
	cData.addValue("GUID", sItemExecGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}
bool selectImageItemExecByItemExecID(const QString sItemExecGuid, QVector<QSqlRecord>& vecRecord, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sSql = "select * from prob_image_item_exec_records where GUID=?";
	cData.sTableName = "prob_image_item_exec_records";
	cData.addValue("GUID", sItemExecGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	vecRecord = cData.vecRecord;
	return bRet;
}
bool selectTemplateBySceneID(const QString sSceneGuid, QMap<QString, CTemplateInfo*>& mapTemplate, QString & sErrMsg)
{
	mapTemplate.clear();
	CDatabaseExecData cData;
	cData.sTableName = "prob_template_config";
	cData.sSql = "select * from prob_template_config where SCENE_GUID=? and LATEST_RECORD = 1";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("SCENE_GUID");
	cData.vecValue.push_back(sSceneGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	for (int i = 0; i < vecDataInfo.size(); i++)
	{
		CTemplateInfo* pTemplate = new CTemplateInfo();
		pTemplate->m_sTemplateFixedID = vecDataInfo[i].value("TEMPLATE_FIXED_ID").toString();
		pTemplate->m_sTemplateGuid = vecDataInfo[i].value("GUID").toString();
		pTemplate->m_sTemplateName = vecDataInfo[i].value("TEMPLATE_NAME").toString();
		pTemplate->m_sGuid = sSceneGuid;
		pTemplate->m_nActOrder = vecDataInfo[i].value("TEMPLATE_EXEC_ORDER").toInt();
		pTemplate->m_nLatestRecord = vecDataInfo[i].value("LATEST_RECORD").toInt();
		pTemplate->m_nItemCount = vecDataInfo[i].value("ITEM_COUNT").toInt();
		pTemplate->m_dPollSpeed = vecDataInfo[i].value("POLL_SPEED").toDouble();
		pTemplate->m_dSpeedZ = vecDataInfo[i].value("SPEED_Z").toDouble();
		pTemplate->m_sUpdateTime = vecDataInfo[i].value("UPDATE_TIME").toDateTime().toString("yyyy/MM/dd hh:mm:ss");
		QString sItemGuids = vecDataInfo[i].value("ITEM_GUID").toString();
		QStringList slist = sItemGuids.split("-");//巡检项GUID用‘-’分隔
		for (int i = 0; i < slist.size(); i++)
		{
			QString sItemGuid = slist.at(i);
			pTemplate->m_vecItemID.push_back(sItemGuid);
		}
		QString sItemOrders = vecDataInfo[i].value("ITEM_ORDER").toString();
		QStringList slistOrder = sItemOrders.split("-");//用‘-’分隔
		for (int i = 0; i < slistOrder.size(); i++)
		{
			pTemplate->m_vecItemOrder.push_back(slistOrder.at(i));
		}
		mapTemplate.insert(vecDataInfo[i].value("TEMPLATE_FIXED_ID").toString(), pTemplate);
	}
	return bRet;
}

bool deleteTemplateByFixedGuid(QString & sTemplateFixedId, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_template_config";
	cData.sSql = "delete from prob_template_config where TEMPLATE_FIXED_ID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.addValue("TEMPLATE_FIXED_ID", sTemplateFixedId);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool addTemplate(CTemplateInfo & templateInfo, QString & sErrMsg)
{
	QString sItem = "";
	QString sOrder = "";
	for (int i = 0; i < templateInfo.m_vecItemID.size(); i++)
	{
		sItem += templateInfo.m_vecItemID[i];
		if (i < templateInfo.m_vecItemID.size() - 1)
		{
			sItem += "-";
		}
	}

	for (int i = 0; i < templateInfo.m_vecItemOrder.size(); i++)
	{
		sOrder += templateInfo.m_vecItemOrder[i];
		if (i < templateInfo.m_vecItemOrder.size() - 1)
		{
			sOrder += "-";
		}
	}
	CDatabaseExecData cData;
	cData.sTableName = "prob_template_config";
	cData.sSql = "insert into prob_template_config (GUID,TEMPLATE_FIXED_ID,TEMPLATE_NAME,SCENE_GUID,ITEM_COUNT,ITEM_GUID,TEMPLATE_EXEC_ORDER,POLL_SPEED,UPDATE_TIME,LATEST_RECORD,SPEED_Z,ITEM_ORDER)"
		" values(?,?,?,?,?,?,?,?,?,?,?,?)";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.addValue("GUID", templateInfo.m_sTemplateGuid);
	cData.addValue("TEMPLATE_FIXED_ID", templateInfo.m_sTemplateFixedID);
	cData.addValue("TEMPLATE_NAME", templateInfo.m_sTemplateName);
	cData.addValue("SCENE_GUID", templateInfo.m_sGuid);
	cData.addValue("ITEM_COUNT", templateInfo.m_nItemCount);
	cData.addValue("ITEM_GUID", sItem);
	cData.addValue("TEMPLATE_EXEC_ORDER", templateInfo.m_nActOrder);
	cData.addValue("POLL_SPEED", templateInfo.m_dPollSpeed);
	cData.addValue("UPDATE_TIME", templateInfo.m_sUpdateTime);
	cData.addValue("LATEST_RECORD", templateInfo.m_nLatestRecord);
	cData.addValue("SPEED_Z", templateInfo.m_dSpeedZ);
	cData.addValue("ITEM_ORDER", sOrder);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool setTemplateOldByFixedId(QString sTemplateFixedId, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_template_config";
	cData.sSql = "update prob_template_config set LATEST_RECORD = 0,UPDATE_TIME=?  where TEMPLATE_FIXED_ID=?";
	cData.addValue("UPDATE_TIME", QDateTime::currentDateTime());
	cData.addValue("TEMPLATE_FIXED_ID", sTemplateFixedId);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

CTemplateInfo selectTemplateInfo(QString sTemplateFixedId, QString & sErrMsg)
{
	CTemplateInfo cTemplate;
	CDatabaseExecData cData;
	cData.sTableName = "prob_template_config";
	cData.sSql = "select * from prob_template_config where TEMPLATE_FIXED_ID=? and LATEST_RECORD=?";
	cData.addValue("TEMPLATE_FIXED_ID", sTemplateFixedId);
	cData.addValue("LATEST_RECORD", 1);
	CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	QVector<QSqlRecord> vecDataInfo = cData.vecRecord;
	if (vecDataInfo.size() > 0)
	{
		cTemplate.m_sTemplateFixedID = vecDataInfo[0].value("TEMPLATE_FIXED_ID").toString();
		cTemplate.m_sTemplateGuid = vecDataInfo[0].value("GUID").toString();
		cTemplate.m_sTemplateName = vecDataInfo[0].value("TEMPLATE_NAME").toString();
		cTemplate.m_nActOrder = vecDataInfo[0].value("TEMPLATE_EXEC_ORDERUID").toInt();
		cTemplate.m_nLatestRecord = vecDataInfo[0].value("LATEST_RECORD").toInt();
		cTemplate.m_nItemCount = vecDataInfo[0].value("ITEM_COUNT").toInt();
		cTemplate.m_dPollSpeed = vecDataInfo[0].value("POLL_SPEED").toDouble();
		cTemplate.m_dSpeedZ = vecDataInfo[0].value("SPEED_Z").toDouble();
		cTemplate.m_sUpdateTime = vecDataInfo[0].value("UPDATE_TIME").toString();
		QString sItemGuids = vecDataInfo[0].value("ITEM_GUID").toString();
		QString sItemOrder = vecDataInfo[0].value("ITEM_ORDER").toString();
		QStringList slist = sItemGuids.split("-");//巡检项GUID用‘-’分隔
		QStringList slistOrder = sItemOrder.split("-");//巡检项GUID用‘-’分隔
		for (int i = 0; i < slist.size(); i++)
		{
			QString sItemGuid = slist.at(i);
			cTemplate.m_vecItemID.push_back(sItemGuid);
			if (slistOrder.size() > i)
			{
				cTemplate.m_vecItemOrder.push_back(slistOrder[i]);
			}
		}
	}
	return cTemplate;
}

bool updatePloItemSensorByItemID(const CPolItemSensor & item, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_item_config_sensor";
	cData.sSql = "UPDATE prob_poll_item_config_sensor SET POLL_ITEM_NAME=?,ITEM_DEVICE_TYPE_CODE=?,ALARM_LEVEL=?,DATA_THRESHOLD_HH=?,DATA_THRESHOLD_H=?,DATA_THRESHOLD_LL=?,DATA_THRESHOLD_L=?,ITEM_INDEX=?,BELONG=?,CHECK_TYPE=?,COLLECT_INDEX=?,COLLECT_CHECK_TYPE=?,COLLECT_ROLLER_NUM=?,COLLECT_INTERVAL=? "
		"WHERE GUID=?";
	cData.addValue("POLL_ITEM_NAME", item.m_sItemName);
	cData.addValue("ITEM_DEVICE_TYPE_CODE", item.m_nDevTypeCode);
	cData.addValue("ALARM_LEVEL", item.m_nAlarmLevel);
	cData.addValue("DATA_THRESHOLD_HH", item.m_sDataThreadHoldHH);
	cData.addValue("DATA_THRESHOLD_H", item.m_sDataThreadHoldH);
	cData.addValue("DATA_THRESHOLD_LL", item.m_sDataThreadHoldLL);
	cData.addValue("DATA_THRESHOLD_L", item.m_sDataThreadHoldL);
	cData.addValue("ITEM_INDEX", item.m_nIndex);
	cData.addValue("BELONG", item.m_nBelong);
	cData.addValue("CHECK_TYPE", item.m_nCheckType);
	cData.addValue("COLLECT_INDEX", item.m_nCollectIndex);
	cData.addValue("COLLECT_CHECK_TYPE", item.m_nCollectCheckType);
	cData.addValue("COLLECT_ROLLER_NUM", item.m_nCollectRollerNum);
	cData.addValue("COLLECT_INTERVAL", item.m_dCollectInterval);
	cData.addValue("GUID", item.m_sItemGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool updatePloItemCamerByItemID(const CPolItemCamer & item, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_item_config_pan";
	cData.sSql = "UPDATE prob_poll_item_config_pan SET POLL_ITEM_NAME=?,ITEM_DEVICE_TYPE_CODE=?,CHECK_TYPE=?,COLLECT_INDEX=?,TACK_PICTURE=?,"
		"DATA_TYPE=?,ITEMZ=?,COLLECT_TIME=?,ALARM_LEVEL=?,DATA_THRESHOLD_HH=?,DATA_THRESHOLD_H=?,DATA_THRESHOLD_LL=?,DATA_THRESHOLD_L=?,ANGEL_CAMER=?,COLLECT_INTERVAL=?,ITEM_INDEX=?,BELONG=?,COLLECT_CHECK_TYPE=?,COLLECT_ROLLER_NUM=?,ROLLER_OFFSET_DIS=?,IS_EXEC_AI=?,IS_SHOW_PDF=? "
		"WHERE GUID=?";
	cData.addValue("POLL_ITEM_NAME", item.m_sItemName);
	cData.addValue("ITEM_DEVICE_TYPE_CODE", item.m_nDevTypeCode);
	cData.addValue("CHECK_TYPE", item.m_nCheckType);
	cData.addValue("COLLECT_INDEX", item.m_nCollectIndex);
	cData.addValue("TACK_PICTURE", item.m_nTackPicture);
	cData.addValue("DATA_TYPE", item.m_nDataType);
	cData.addValue("ITEMZ", item.m_dItemZ);//巡检项坐标Z(现在是cm)
	cData.addValue("COLLECT_TIME", item.m_dCollectTime);
	cData.addValue("ALARM_LEVEL", item.m_nAlarmLevel);
	cData.addValue("DATA_THRESHOLD_HH", item.m_sDataThreadHoldHH);
	cData.addValue("DATA_THRESHOLD_H", item.m_sDataThreadHoldH);
	cData.addValue("DATA_THRESHOLD_LL", item.m_sDataThreadHoldLL);
	cData.addValue("DATA_THRESHOLD_L", item.m_sDataThreadHoldL);
	cData.addValue("ANGEL_CAMER", item.m_dAngelCamer);
	cData.addValue("COLLECT_INTERVAL", item.m_dCollectInterval);
	cData.addValue("ITEM_INDEX", item.m_nIndex);
	cData.addValue("BELONG", item.m_nBelong);
	cData.addValue("COLLECT_CHECK_TYPE", item.m_nCollectCheckType);
	cData.addValue("COLLECT_ROLLER_NUM", item.m_nCollectRollerNum);
	cData.addValue("ROLLER_OFFSET_DIS", item.m_dRollerOffdetDis);
	cData.addValue("IS_EXEC_AI", item.m_nIsExecAI);
	cData.addValue("IS_SHOW_PDF", item.m_nIsShowPdf);
	cData.addValue("GUID", item.m_sItemGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool addPloItemSensor(const CPolItemSensor & item, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_item_config_sensor";
	cData.sSql = "insert into prob_poll_item_config_sensor (GUID,POLL_ITEM_NAME,SCENE_GUID,POLL_POINT_GUID,DEVICE_TYPE,ITEM_DEVICE_TYPE_CODE,"
		"ALARM_LEVEL,DATA_THRESHOLD_HH,DATA_THRESHOLD_H,DATA_THRESHOLD_LL,DATA_THRESHOLD_L,ITEM_INDEX,BELONG,CHECK_TYPE,COLLECT_INDEX,COLLECT_CHECK_TYPE,COLLECT_ROLLER_NUM,COLLECT_INTERVAL) "
		"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
	cData.addValue("GUID", item.m_sItemGuid);
	cData.addValue("POLL_ITEM_NAME", item.m_sItemName);
	cData.addValue("SCENE_GUID", item.m_sGuid);
	cData.addValue("POLL_POINT_GUID", item.m_sPointGuid);
	cData.addValue("DEVICE_TYPE", 0);
	cData.addValue("ITEM_DEVICE_TYPE_CODE", item.m_nDevTypeCode);
	cData.addValue("ALARM_LEVEL", item.m_nAlarmLevel);
	cData.addValue("DATA_THRESHOLD_HH", item.m_sDataThreadHoldHH);
	cData.addValue("DATA_THRESHOLD_H", item.m_sDataThreadHoldH);
	cData.addValue("DATA_THRESHOLD_LL", item.m_sDataThreadHoldLL);
	cData.addValue("DATA_THRESHOLD_L", item.m_sDataThreadHoldL);
	cData.addValue("ITEM_INDEX", item.m_nIndex);
	cData.addValue("BELONG", item.m_nBelong);
	cData.addValue("CHECK_TYPE", item.m_nCheckType);
	cData.addValue("COLLECT_INDEX", item.m_nCollectIndex);
	cData.addValue("COLLECT_CHECK_TYPE", item.m_nCollectCheckType);
	cData.addValue("COLLECT_ROLLER_NUM", item.m_nCollectRollerNum);
	cData.addValue("COLLECT_INTERVAL", item.m_dCollectInterval);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool addPloItemCarmer(const CPolItemCamer & item, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_item_config_pan";
	cData.sSql = "insert into prob_poll_item_config_pan (GUID,POLL_ITEM_NAME,SCENE_GUID,POLL_POINT_GUID,DEVICE_TYPE,ITEM_DEVICE_TYPE_CODE,CHECK_TYPE,"
		"COLLECT_INDEX,TACK_PICTURE,"
		"DATA_TYPE,ITEMZ,COLLECT_TIME,ALARM_LEVEL,DATA_THRESHOLD_HH,DATA_THRESHOLD_H,DATA_THRESHOLD_LL,DATA_THRESHOLD_L,ANGEL_CAMER,ITEM_INDEX,COLLECT_INTERVAL,BELONG,COLLECT_CHECK_TYPE,COLLECT_ROLLER_NUM,ROLLER_OFFSET_DIS,IS_EXEC_AI,IS_SHOW_PDF)"
		"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
	cData.addValue("GUID", item.m_sItemGuid);
	cData.addValue("POLL_ITEM_NAME", item.m_sItemName);
	cData.addValue("SCENE_GUID", item.m_sGuid);
	cData.addValue("POLL_POINT_GUID", item.m_sPointGuid);
	cData.addValue("DEVICE_TYPE", 1);
	cData.addValue("ITEM_DEVICE_TYPE_CODE", item.m_nDevTypeCode);
	cData.addValue("CHECK_TYPE", item.m_nCheckType);
	cData.addValue("COLLECT_INDEX", item.m_nCollectIndex);
	cData.addValue("TACK_PICTURE", item.m_nTackPicture);
	cData.addValue("DATA_TYPE", item.m_nDataType);
	cData.addValue("ITEMZ", item.m_dItemZ);//巡检项坐标Z(现在是cm)
	cData.addValue("COLLECT_TIME", item.m_dCollectTime);
	cData.addValue("ALARM_LEVEL", item.m_nAlarmLevel);
	cData.addValue("DATA_THRESHOLD_HH", item.m_sDataThreadHoldHH);
	cData.addValue("DATA_THRESHOLD_H", item.m_sDataThreadHoldH);
	cData.addValue("DATA_THRESHOLD_LL", item.m_sDataThreadHoldLL);
	cData.addValue("DATA_THRESHOLD_L", item.m_sDataThreadHoldL);
	cData.addValue("ANGEL_CAMER", item.m_dAngelCamer);
	cData.addValue("ITEM_INDEX", item.m_nIndex);
	cData.addValue("COLLECT_INTERVAL", item.m_dCollectInterval);
	cData.addValue("BELONG", item.m_nBelong);
	cData.addValue("COLLECT_CHECK_TYPE", item.m_nCollectCheckType);
	cData.addValue("COLLECT_ROLLER_NUM", item.m_nCollectRollerNum);
	cData.addValue("ROLLER_OFFSET_DIS", item.m_dRollerOffdetDis);
	cData.addValue("IS_EXEC_AI", item.m_nIsExecAI);
	cData.addValue("IS_SHOW_PDF", item.m_nIsShowPdf);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool addPolPointInfo(CPolPoint * pPoint, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_point_config";
	cData.sSql = "insert into prob_poll_point_config (GUID,POLL_POINT_NAME,POLL_AREA_GUID,SCENE_GUID,POINT_LOCATION,POINT_X,POINT_Y,POINT_Z,IS_CHARGING_POINT)"
		" values(?,?,?,?,?,?,?,?,?)";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.addValue("GUID", pPoint->m_sPointGuid);
	cData.addValue("POLL_POINT_NAME", pPoint->m_sPointName);
	cData.addValue("POLL_AREA_GUID", pPoint->m_sPolAreaGuid);
	cData.addValue("SCENE_GUID", pPoint->m_sGuid);
	cData.addValue("POINT_LOCATION", pPoint->m_dPointLocation);
	cData.addValue("POINT_X", pPoint->m_dPointX);
	cData.addValue("POINT_Y", pPoint->m_dPointY);
	cData.addValue("POINT_Z", pPoint->m_dPointZ);
	cData.addValue("IS_CHARGING_POINT", pPoint->m_nIsChargePoint);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool delPolPoint(QString sPointGuid, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_point_config";
	cData.sSql = "delete from prob_poll_point_config where GUID=?";
	cData.addValue("GUID", sPointGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool delPolPoint(QString sSceneGuid, QVector<QString> vecPointGuid, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_point_config";
	cData.sSql = "delete from prob_poll_point_config where SCENE_GUID =? ";
	cData.addValue("SCENE_GUID", sSceneGuid);
	for (int i = 0; i < vecPointGuid.size(); i++)
	{
		cData.sSql += "AND GUID != ? ";
		cData.addValue("GUID", vecPointGuid[i]);
	}
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool delPolItem(QString sSceneGuid, QVector<QString> vecPointGuid, QString & sErrMsg)
{
	{
		CDatabaseExecData cData;
		cData.sTableName = "prob_poll_item_config_sensor";
		cData.sSql = "delete from prob_poll_item_config_sensor where  SCENE_GUID =? ";
		cData.addValue("SCENE_GUID", sSceneGuid);
		for (int i = 0; i < vecPointGuid.size(); i++)
		{
			cData.sSql += "AND POLL_POINT_GUID != ? ";
			cData.addValue("POLL_POINT_GUID", vecPointGuid[i]);
		}
		bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
		sErrMsg = cData.sErr;
		if (!bRet)
		{
			return false;
		}

	}
	{
		CDatabaseExecData cData;
		cData.sTableName = "prob_poll_item_config_pan";
		cData.sSql = "delete from prob_poll_item_config_pan where SCENE_GUID =?  ";
		cData.addValue("SCENE_GUID", sSceneGuid);
		for (int i = 0; i < vecPointGuid.size(); i++)
		{
			cData.sSql += "AND POLL_POINT_GUID != ? ";
			cData.addValue("POLL_POINT_GUID", vecPointGuid[i]);
		}
		bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
		sErrMsg = cData.sErr;
		return bRet;
	}
}

bool delPolItemEx(QString sSceneGuid, QString sPointGuid, QVector<QString> vecItemGuid, QString & sErrMsg)
{
	{
		CDatabaseExecData cData;
		cData.sTableName = "prob_poll_item_config_sensor";
		cData.sSql = "delete from prob_poll_item_config_sensor where SCENE_GUID =? AND POLL_POINT_GUID =? ";
		cData.addValue("SCENE_GUID", sSceneGuid);
		cData.addValue("POLL_POINT_GUID", sPointGuid);
		for (int i = 0; i < vecItemGuid.size(); i++)
		{
			cData.sSql += "AND GUID != ? ";
			cData.addValue("GUID", vecItemGuid[i]);
		}
		bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
		sErrMsg = cData.sErr;
		if (!bRet)
		{
			return false;
		}
	}
	{
		CDatabaseExecData cData;
		cData.sTableName = "prob_poll_item_config_pan";
		cData.sSql = "delete from prob_poll_item_config_pan where SCENE_GUID =? AND POLL_POINT_GUID =? ";
		cData.addValue("SCENE_GUID", sSceneGuid);
		cData.addValue("POLL_POINT_GUID", sPointGuid);
		for (int i = 0; i < vecItemGuid.size(); i++)
		{
			cData.sSql += "AND GUID != ? ";
			cData.addValue("GUID", vecItemGuid[i]);
		}
		bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
		sErrMsg = cData.sErr;
		return bRet;
	}
}

bool updatePointName(QString sPointGuid, QString sPointName, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_point_config";
	cData.sSql = "UPDATE prob_poll_point_config SET POLL_POINT_NAME=? WHERE GUID=?";
	cData.addValue("POLL_POINT_NAME", sPointName);
	cData.addValue("GUID", sPointGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool updatePointLocation(QString sPointGuid, double dLocation, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_point_config";
	cData.sSql = "UPDATE prob_poll_point_config SET POINT_LOCATION=? WHERE GUID=?";
	cData.addValue("POINT_LOCATION", dLocation);
	cData.addValue("GUID", sPointGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool updatePointCharge(QString sPointGuid, int nIsCharge, QString & sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_poll_point_config";
	cData.sSql = "UPDATE prob_poll_point_config SET IS_CHARGING_POINT=? WHERE GUID=?";
	cData.addValue("IS_CHARGING_POINT", nIsCharge);
	cData.addValue("GUID", sPointGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool addRobHost(QString sSceneGuid, CDevDataBase* pDevData, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_robot_basic_config";
	cData.sSql = "insert into prob_robot_basic_config (ROBOT_HOST_ID,SCENE_GUID,IP_ADDRESS,PORT_NUMBER,ROBOT_NAME,ROBOT_RUN_SPEED,"
		"ROBOT_RUN_SPEEDZ,DEVICE_ENUM,ROBOT_TYPE,SAFE_DISTANCE,ROBOT_WORK_TYPE,CORSE,PROXIMITY_SENSOR_OFFSET,NO2_LABEL_OFFSET,"
		"IS_OPEN_AUTO_CHARGEL,AUTO_CHARGE_THRESHOLD,RETURN_SPEED,FRONT_OBSTACLE_AVOIDANCE,BACK_OBSTACLE_AVOIDANCE,"
		"CHARGE_CUTOFF_THRESHOLD,CHARGE_CUTOFF_VOLTAGE,HOLDING_ADDPOWER_THRESHOLD,HOLDING_ADDPOWER_VOLTAGE,TASK_ELE_QUANTITY_THRESHOLD,"
		"TASK_ELE_QUANTITY_VOLTAGE,FORCE_CHARGE_THRESHOLD,FORCE_CHARGE_VOLTAGE,CHARGE_FAIL_LOOP_COUNT,CHARGE_COMMUNICATION_DELAY,CHARGE_AUTO_RETORN_DISTANCE,"
		"LEVEL_ONE_SPEED_CUT,LEVEL_TWO_SPEED_CUT,DRIVE_MOTOR_UPPER_CURRENT,DRIVE_MOTOR_CURRENT_SLEEP,DRIVE_MOTOR_UPPER_TORQUE,"
		"DRIVE_MOTOR_TORQUE_SLEEP,DRIVE_MOTOR_UPPER_TEMP,DRIVE_MOTOR_TEMP_SLEEP,LIFT_MOTOR_UPPER_CURRENT,LIFT_MOTOR_CURRENT_SLEEP,"
		"LIFT_MOTOR_UPPER_TORQUE,LIFT_MOTOR_TORQUE_SLEEP,LIFT_MOTOR_UPPER_TEMP,LIFT_MOTOR_TEMP_SLEEP,LIFT_MOTOR_SPEED_SET,"
		"ONE_CLICK_BACK_LOCATION,AUTO_SWITCH_OPEN_BATTERY_THRE,AUTO_SWITCH_OPEN_VOL_THRE,IS_AUTO_FLUSH,FLUSH_RFID1,FLUSH_RFID2,FLUSH_PLACE_OFFSET,ROLLER_START_LOC,ROLLER_END_LOC,ROLLER_INTERVAL)"
		" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

	cData.addValue("ROBOT_HOST_ID", pDevData->m_sDevGuid);
	cData.addValue("SCENE_GUID", sSceneGuid);
	cData.addValue("IP_ADDRESS", pDevData->m_sRobotIp);
	cData.addValue("PORT_NUMBER", pDevData->m_sRobotPort);
	cData.addValue("ROBOT_NAME", pDevData->m_sRobName);
	cData.addValue("ROBOT_RUN_SPEED", pDevData->m_dRobRunSpeed);
	cData.addValue("ROBOT_RUN_SPEEDZ", pDevData->m_dRobRunSpeedZ);

	cData.addValue("DEVICE_ENUM", pDevData->m_nDeviceEnum);
	cData.addValue("ROBOT_TYPE", pDevData->m_nRobType);
	cData.addValue("SAFE_DISTANCE", pDevData->m_dSafeDistance);
	cData.addValue("ROBOT_WORK_TYPE", pDevData->m_nRobWorkType);
	cData.addValue("CORSE", pDevData->m_dCorse);

	cData.addValue("PROXIMITY_SENSOR_OFFSET", pDevData->m_nProximitySensorOffset);
	cData.addValue("NO2_LABEL_OFFSET", pDevData->m_nNo2LabelOffset);
	cData.addValue("IS_OPEN_AUTO_CHARGEL", pDevData->m_nIsOpenAutoCharge);
	cData.addValue("AUTO_CHARGE_THRESHOLD", pDevData->m_nAutoChargeThreshold);
	cData.addValue("RETURN_SPEED", pDevData->m_dReturnSpeed);

	cData.addValue("FRONT_OBSTACLE_AVOIDANCE", pDevData->m_dFrontObstacleAvoidance);
	cData.addValue("BACK_OBSTACLE_AVOIDANCE", pDevData->m_dBackObstanceAvidance);
	cData.addValue("CHARGE_CUTOFF_THRESHOLD", pDevData->m_dChargeCutOffThreshold);
	cData.addValue("CHARGE_CUTOFF_VOLTAGE", pDevData->m_dChargeCutOffVolTage);
	cData.addValue("HOLDING_ADDPOWER_THRESHOLD", pDevData->m_dHoldingAddPowerThreshold);

	cData.addValue("HOLDING_ADDPOWER_VOLTAGE", pDevData->m_dHoldingAddPowerVoltage);
	cData.addValue("TASK_ELE_QUANTITY_THRESHOLD", pDevData->m_dTaskEleQuantityThreshold);
	cData.addValue("TASK_ELE_QUANTITY_VOLTAGE", pDevData->m_dTaskEleQuantityVoltage);
	cData.addValue("FORCE_CHARGE_THRESHOLD", pDevData->m_dForceChargeThreshold);
	cData.addValue("FORCE_CHARGE_VOLTAGE", pDevData->m_dForceChargeVoltage);

	cData.addValue("CHARGE_FAIL_LOOP_COUNT", pDevData->m_dChargeFallLoopCount);
	cData.addValue("CHARGE_COMMUNICATION_DELAY", pDevData->m_dChargeCommunicationDelay);
	cData.addValue("CHARGE_AUTO_RETORN_DISTANCE", pDevData->m_dChargeAutoRetornDistance);
	cData.addValue("LEVEL_ONE_SPEED_CUT", pDevData->m_dLevelOneSpeedCut);
	cData.addValue("LEVEL_TWO_SPEED_CUT", pDevData->m_dLevelTwoSpeedCut);

	cData.addValue("DRIVE_MOTOR_UPPER_CURRENT", pDevData->m_dDriveMotorUpperCurrent);
	cData.addValue("DRIVE_MOTOR_CURRENT_SLEEP", pDevData->m_dDriveMotorCurrentSleep);
	cData.addValue("DRIVE_MOTOR_UPPER_TORQUE", pDevData->m_dDriveMotorUpperTorque);
	cData.addValue("DRIVE_MOTOR_TORQUE_SLEEP", pDevData->m_dDriveMotorTorqueSleep);
	cData.addValue("DRIVE_MOTOR_UPPER_TEMP", pDevData->m_dDriveMotorUpperTemp);

	cData.addValue("DRIVE_MOTOR_TEMP_SLEEP", pDevData->m_dDriveMotorTempSleep);
	cData.addValue("LIFT_MOTOR_UPPER_CURRENT", pDevData->m_dLiftMotorUpperCurrent);
	cData.addValue("LIFT_MOTOR_CURRENT_SLEEP", pDevData->m_dLiftMotorCurrentSleep);
	cData.addValue("LIFT_MOTOR_UPPER_TORQUE", pDevData->m_dLiftMotorUpperTorque);
	cData.addValue("LIFT_MOTOR_TORQUE_SLEEP", pDevData->m_dLiftMotorTorqueSleep);

	cData.addValue("LIFT_MOTOR_UPPER_TEMP", pDevData->m_dLiftMotorUpperTemp);
	cData.addValue("LIFT_MOTOR_TEMP_SLEEP", pDevData->m_dLiftMotorTempSleep);
	cData.addValue("LIFT_MOTOR_SPEED_SET", pDevData->m_dLiftMotorSleepSet);
	cData.addValue("ONE_CLICK_BACK_LOCATION", pDevData->m_dOneClickBaceLocation);

	/*额外添加冲洗*/
	cData.addValue("AUTO_SWITCH_OPEN_BATTERY_THRE", pDevData->m_dAutoSwitchOpenBatteryThre);
	cData.addValue("AUTO_SWITCH_OPEN_VOL_THRE", pDevData->m_dAutoSwitchOpenVolThre);
	cData.addValue("IS_AUTO_FLUSH", pDevData->m_dIsAutoFlush);
	cData.addValue("FLUSH_RFID1", pDevData->m_nFlushRFID1);
	cData.addValue("FLUSH_RFID2", pDevData->m_nFlushRFID2);
	cData.addValue("FLUSH_PLACE_OFFSET", pDevData->m_dFlushPlaceOffset);

	/*额外添加托辊 wxy++ */
	cData.addValue("ROLLER_START_LOC", "");
	cData.addValue("ROLLER_END_LOC", "");
	cData.addValue("ROLLER_INTERVAL", "");

	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool addRobPanTilt(CDevDataCam* pDevDataRob, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_pan_tilt_config";
	cData.sSql = "insert into prob_pan_tilt_config (PAN_TILT_ID,PAN_TILT_NAME,ROBOT_HOST_ID,PAN_TILT_TYPE,IR_CAMERA_CODE,"
		"IMAGE_CAMERA_CODE,AUDIO_DEVICE_CODE,PAN_TILT_IP,PAN_TILT_PORT,USER_NAME,PASSWORD,MANUAL_RECORD_PATH,PAN_TILT_OBS_CONFIG,HW_RTSP_URL,GQ_RTSP_URL)"
		" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

	cData.addValue("PAN_TILT_ID", pDevDataRob->m_sCamerGuid);
	cData.addValue("PAN_TILT_NAME", pDevDataRob->m_sCamerName);
	cData.addValue("ROBOT_HOST_ID", pDevDataRob->m_sRobHostGuid);
	cData.addValue("PAN_TILT_TYPE", pDevDataRob->m_sCamerType);
	cData.addValue("IR_CAMERA_CODE", pDevDataRob->m_sIRCamerCode);
	cData.addValue("IMAGE_CAMERA_CODE", pDevDataRob->m_sImageCamerCode);
	cData.addValue("AUDIO_DEVICE_CODE", pDevDataRob->m_sAudioDeviceCode);
	cData.addValue("PAN_TILT_IP", pDevDataRob->m_sCamerIp);
	cData.addValue("PAN_TILT_PORT", pDevDataRob->m_nCamerPort);
	cData.addValue("USER_NAME", pDevDataRob->m_sUserName);
	cData.addValue("PASSWORD", pDevDataRob->m_sPassWord);
	cData.addValue("MANUAL_RECORD_PATH", pDevDataRob->m_sRecordPath);
	cData.addValue("PAN_TILT_OBS_CONFIG", pDevDataRob->m_sCamerObsConfig);
	cData.addValue("HW_RTSP_URL", pDevDataRob->m_sRtspUrlIr);
	cData.addValue("GQ_RTSP_URL", pDevDataRob->m_sRtspUrlImg);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool addRobModbus(QString sRobGuid, QList<QStringList> listModbusData, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_io_allocation_table";
	cData.sSql = "insert into prob_io_allocation_table (IO_TYPE,ROBOT_HOST_ID,START_ADDRESS,DATA_LENGTH,ADDRESS_DESC,TYPE)"
		" values ";
	for (QStringList listData : listModbusData)
	{
		cData.sSql.append("(");
		cData.sSql.push_back(listData[0] + ",");
		cData.sSql.push_back("'" + sRobGuid + "',");
		cData.sSql.push_back("'" + listData[1] + "',");
		cData.sSql.push_back("'" + listData[2] + "',");
		cData.sSql.push_back("'" + listData[3] + "',");
		cData.sSql.push_back(listData[4]);
		cData.sSql.append("),");
	}
	cData.sSql.chop(1);

	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool addRobSensorMulti(QString sRobGuid, QVector<SSensorInfo> vecSensor, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_sensor_config";
	cData.sSql = "insert into prob_sensor_config (GUID,SENSOR_TYPE_CODE,SENSOR_NAME,ROBOT_HOST_ID,SENSOR_ENABLED)"
		" values ";

	for (SSensorInfo stSensorInfo : vecSensor)
	{
		cData.sSql.append("(");
		cData.sSql.push_back("'" + stSensorInfo.m_sGuid + "',");
		cData.sSql.push_back("'" + stSensorInfo.m_sSnesorType + "',");
		cData.sSql.push_back("'" + stSensorInfo.m_sSensorName + "',");
		cData.sSql.push_back("'" + sRobGuid + "',");
		cData.sSql.push_back(QString::number(static_cast<int>(stSensorInfo.m_bEnaled)));
		cData.sSql.append("),");
	}
	cData.sSql.chop(1);

	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}


bool deleteDeviceInfo(QString sId)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_device_info";
	cData.sSql = "delete from prob_device_info where ID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecValue.push_back(sId);
	cData.vecField.push_back("ID");
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	return bRet;
}

bool selectRobConfig(QString sGuid, CDevDataBase* pDevDataRob)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_robot_basic_config";
	cData.sSql = "select * from prob_robot_basic_config where ROBOT_HOST_ID=?";
	cData.vecField.clear();
	cData.vecValue.clear();
	cData.vecField.push_back("ROBOT_HOST_ID");
	cData.vecValue.push_back(sGuid);
	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	if (!bRet || cData.vecRecord.size() <= 0)
	{
		return false;
	}

	CDatabaseExecData cDataPan;
	cDataPan.sTableName = "prob_pan_tilt_config";
	cDataPan.sSql = "select * from prob_pan_tilt_config where ROBOT_HOST_ID=?";
	cDataPan.vecField.clear();
	cDataPan.vecValue.clear();
	cDataPan.vecField.push_back("ROBOT_HOST_ID");
	cDataPan.vecValue.push_back(sGuid);
	bool bRetPan = CPublicData::instance().m_pSqlDllOper->exec(cDataPan);
	if (!bRetPan || cDataPan.vecRecord.size() <= 0)
	{
		return false;
	}
	pDevDataRob->m_sRobotIp = cData.vecRecord[0].value("IP_ADDRESS").toString();
	pDevDataRob->m_sRobotPort = cData.vecRecord[0].value("PORT_NUMBER").toString();
	pDevDataRob->m_sRobName = cData.vecRecord[0].value("ROBOT_NAME").toString();
	pDevDataRob->m_dRobRunSpeed = cData.vecRecord[0].value("ROBOT_RUN_SPEED").toDouble();
	pDevDataRob->m_dRobRunSpeedZ = cData.vecRecord[0].value("ROBOT_RUN_SPEEDZ").toDouble();

	pDevDataRob->m_nDeviceEnum = cData.vecRecord[0].value("DEVICE_ENUM").toInt();
	pDevDataRob->m_nRobType = cData.vecRecord[0].value("ROBOT_TYPE").toInt();
	pDevDataRob->m_dSafeDistance = cData.vecRecord[0].value("SAFE_DISTANCE").toDouble();
	pDevDataRob->m_nRobWorkType = cData.vecRecord[0].value("ROBOT_WORK_TYPE").toInt();
	pDevDataRob->m_dCorse = cData.vecRecord[0].value("CORSE").toDouble();

	pDevDataRob->m_nProximitySensorOffset = cData.vecRecord[0].value("PROXIMITY_SENSOR_OFFSET").toInt();
	pDevDataRob->m_nNo2LabelOffset = cData.vecRecord[0].value("NO2_LABEL_OFFSET").toInt();
	pDevDataRob->m_nIsOpenAutoCharge = cData.vecRecord[0].value("IS_OPEN_AUTO_CHARGEL").toInt();
	pDevDataRob->m_nAutoChargeThreshold = cData.vecRecord[0].value("AUTO_CHARGE_THRESHOLD").toInt();
	pDevDataRob->m_dReturnSpeed = cData.vecRecord[0].value("RETURN_SPEED").toDouble();

	pDevDataRob->m_dFrontObstacleAvoidance = cData.vecRecord[0].value("FRONT_OBSTACLE_AVOIDANCE").toDouble();
	pDevDataRob->m_dBackObstanceAvidance = cData.vecRecord[0].value("BACK_OBSTACLE_AVOIDANCE").toDouble();
	pDevDataRob->m_dChargeCutOffThreshold = cData.vecRecord[0].value("CHARGE_CUTOFF_THRESHOLD").toDouble();
	pDevDataRob->m_dChargeCutOffVolTage = cData.vecRecord[0].value("CHARGE_CUTOFF_VOLTAGE").toDouble();
	pDevDataRob->m_dHoldingAddPowerThreshold = cData.vecRecord[0].value("HOLDING_ADDPOWER_THRESHOLD").toDouble();

	pDevDataRob->m_dHoldingAddPowerVoltage = cData.vecRecord[0].value("HOLDING_ADDPOWER_VOLTAGE").toDouble();
	pDevDataRob->m_dTaskEleQuantityThreshold = cData.vecRecord[0].value("TASK_ELE_QUANTITY_THRESHOLD").toDouble();
	pDevDataRob->m_dTaskEleQuantityVoltage = cData.vecRecord[0].value("TASK_ELE_QUANTITY_VOLTAGE").toDouble();
	pDevDataRob->m_dForceChargeThreshold = cData.vecRecord[0].value("FORCE_CHARGE_THRESHOLD").toDouble();
	pDevDataRob->m_dForceChargeVoltage = cData.vecRecord[0].value("FORCE_CHARGE_VOLTAGE").toDouble();

	pDevDataRob->m_dChargeFallLoopCount = cData.vecRecord[0].value("CHARGE_FAIL_LOOP_COUNT").toDouble();
	pDevDataRob->m_dChargeCommunicationDelay = cData.vecRecord[0].value("CHARGE_COMMUNICATION_DELAY").toDouble();
	pDevDataRob->m_dChargeAutoRetornDistance = cData.vecRecord[0].value("CHARGE_AUTO_RETORN_DISTANCE").toDouble();
	pDevDataRob->m_dLevelOneSpeedCut = cData.vecRecord[0].value("LEVEL_ONE_SPEED_CUT").toDouble();
	pDevDataRob->m_dLevelTwoSpeedCut = cData.vecRecord[0].value("LEVEL_TWO_SPEED_CUT").toDouble();

	pDevDataRob->m_dDriveMotorUpperCurrent = cData.vecRecord[0].value("DRIVE_MOTOR_UPPER_CURRENT").toDouble();
	pDevDataRob->m_dDriveMotorCurrentSleep = cData.vecRecord[0].value("DRIVE_MOTOR_CURRENT_SLEEP").toDouble();
	pDevDataRob->m_dDriveMotorUpperTorque = cData.vecRecord[0].value("DRIVE_MOTOR_UPPER_TORQUE").toDouble();
	pDevDataRob->m_dDriveMotorTorqueSleep = cData.vecRecord[0].value("DRIVE_MOTOR_TORQUE_SLEEP").toDouble();
	pDevDataRob->m_dDriveMotorUpperTemp = cData.vecRecord[0].value("DRIVE_MOTOR_UPPER_TEMP").toDouble();

	pDevDataRob->m_dDriveMotorTempSleep = cData.vecRecord[0].value("DRIVE_MOTOR_TEMP_SLEEP").toDouble();
	pDevDataRob->m_dLiftMotorUpperCurrent = cData.vecRecord[0].value("LIFT_MOTOR_UPPER_CURRENT").toDouble();
	pDevDataRob->m_dLiftMotorCurrentSleep = cData.vecRecord[0].value("LIFT_MOTOR_CURRENT_SLEEP").toDouble();
	pDevDataRob->m_dLiftMotorUpperTorque = cData.vecRecord[0].value("LIFT_MOTOR_UPPER_TORQUE").toDouble();
	pDevDataRob->m_dLiftMotorTorqueSleep = cData.vecRecord[0].value("LIFT_MOTOR_TORQUE_SLEEP").toDouble();

	pDevDataRob->m_dLiftMotorUpperTemp = cData.vecRecord[0].value("LIFT_MOTOR_UPPER_TEMP").toDouble();
	pDevDataRob->m_dLiftMotorTempSleep = cData.vecRecord[0].value("LIFT_MOTOR_TEMP_SLEEP").toDouble();
	pDevDataRob->m_dLiftMotorSleepSet = cData.vecRecord[0].value("LIFT_MOTOR_SPEED_SET").toDouble();
	pDevDataRob->m_dOneClickBaceLocation = cData.vecRecord[0].value("ONE_CLICK_BACK_LOCATION").toDouble();
	pDevDataRob->m_dAutoSwitchOpenBatteryThre = cData.vecRecord[0].value("AUTO_SWITCH_OPEN_BATTERY_THRE").toDouble();

	pDevDataRob->m_dAutoSwitchOpenVolThre = cData.vecRecord[0].value("AUTO_SWITCH_OPEN_VOL_THRE").toDouble();
	pDevDataRob->m_dIsAutoFlush = cData.vecRecord[0].value("IS_AUTO_FLUSH").toDouble();
	pDevDataRob->m_nFlushRFID1 = cData.vecRecord[0].value("FLUSH_RFID1").toInt();
	pDevDataRob->m_nFlushRFID2 = cData.vecRecord[0].value("FLUSH_RFID2").toInt();
	pDevDataRob->m_dFlushPlaceOffset = cData.vecRecord[0].value("FLUSH_PLACE_OFFSET").toDouble();

	pDevDataRob->m_nAlarmStopTime = cData.vecRecord[0].value("ALARM_STOP_TIME").toInt();
	pDevDataRob->m_nChargeYTPreset = cData.vecRecord[0].value("CHARGE_YTPRESET").toInt();
	//pDevDataRob->m_sRobObstacle = cData.vecRecord[0].value("OBSTACLE_CFG").toString();
	pDevDataRob->m_nIsHaveFlush = cData.vecRecord[0].value("IS_HAVE_FLUSH").toInt();
	pDevDataRob->m_nCollectTime = cData.vecRecord[0].value("COLLECT_TIME").toInt();
	pDevDataRob->m_nVoiceOffset = cData.vecRecord[0].value("VOICE_OFFSET").toInt();
	pDevDataRob->m_nVoiceAverigeTime = cData.vecRecord[0].value("VOICE_AVERIGE_TIME").toInt();
	pDevDataRob->m_nHumEnable = cData.vecRecord[0].value("HUM_ENABLE").toInt();

	//相机数据
	CDevDataCam* pDevDataCamer = pDevDataRob->m_pDevDataCam;
	pDevDataCamer->m_sRobHostGuid = cDataPan.vecRecord[0].value("ROBOT_HOST_ID").toString();
	pDevDataCamer->m_sCamerGuid = cDataPan.vecRecord[0].value("PAN_TILT_ID").toString();
	pDevDataCamer->m_sCamerName = cDataPan.vecRecord[0].value("PAN_TILT_NAME").toString();
	pDevDataCamer->m_sCamerType = cDataPan.vecRecord[0].value("PAN_TILT_TYPE").toString();
	pDevDataCamer->m_sIRCamerCode = cDataPan.vecRecord[0].value("IR_CAMERA_CODE").toString();
	pDevDataCamer->m_sImageCamerCode = cDataPan.vecRecord[0].value("IMAGE_CAMERA_CODE").toString();
	pDevDataCamer->m_sAudioDeviceCode = cDataPan.vecRecord[0].value("AUDIO_DEVICE_CODE").toString();
	pDevDataCamer->m_sCamerIp = cDataPan.vecRecord[0].value("PAN_TILT_IP").toString();
	pDevDataCamer->m_nCamerPort = cDataPan.vecRecord[0].value("PAN_TILT_PORT").toInt();
	pDevDataCamer->m_sUserName = cDataPan.vecRecord[0].value("USER_NAME").toString();
	pDevDataCamer->m_sPassWord = cDataPan.vecRecord[0].value("PASSWORD").toString();
	pDevDataCamer->m_sRecordPath = cDataPan.vecRecord[0].value("MANUAL_RECORD_PATH").toString();
	pDevDataCamer->m_sCamerObsConfig = cDataPan.vecRecord[0].value("PAN_TILT_OBS_CONFIG").toString();
	pDevDataCamer->m_nBroadcastTime = cDataPan.vecRecord[0].value("BROADCAST_TIME").toInt();

	return true;
}

bool updateRobHostDevice(CDevDataBase* pDevData, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_robot_basic_config";
	cData.sSql = "UPDATE prob_robot_basic_config SET IP_ADDRESS=?,PORT_NUMBER=?,ROBOT_NAME=?,ROBOT_RUN_SPEED=?,ROBOT_RUN_SPEEDZ=?"
			",DEVICE_ENUM=?,ROBOT_TYPE=?,SAFE_DISTANCE=?,ROBOT_WORK_TYPE=?,CORSE=?"
			",PROXIMITY_SENSOR_OFFSET=?,NO2_LABEL_OFFSET=?,IS_OPEN_AUTO_CHARGEL=?,AUTO_CHARGE_THRESHOLD=?,RETURN_SPEED=?"
			",FRONT_OBSTACLE_AVOIDANCE=?,BACK_OBSTACLE_AVOIDANCE=?,CHARGE_CUTOFF_THRESHOLD=?,CHARGE_CUTOFF_VOLTAGE=?,HOLDING_ADDPOWER_THRESHOLD=?"
			",HOLDING_ADDPOWER_VOLTAGE=?,TASK_ELE_QUANTITY_THRESHOLD=?,TASK_ELE_QUANTITY_VOLTAGE=?,FORCE_CHARGE_THRESHOLD=?,FORCE_CHARGE_VOLTAGE=?"
			",CHARGE_FAIL_LOOP_COUNT=?,CHARGE_COMMUNICATION_DELAY=?,CHARGE_AUTO_RETORN_DISTANCE=?,LEVEL_ONE_SPEED_CUT=?,LEVEL_TWO_SPEED_CUT=?"
			",DRIVE_MOTOR_UPPER_CURRENT=?,DRIVE_MOTOR_CURRENT_SLEEP=?,DRIVE_MOTOR_UPPER_TORQUE=?,DRIVE_MOTOR_TORQUE_SLEEP=?,DRIVE_MOTOR_UPPER_TEMP=?"
			",DRIVE_MOTOR_TEMP_SLEEP=?,LIFT_MOTOR_UPPER_CURRENT=?,LIFT_MOTOR_CURRENT_SLEEP=?,LIFT_MOTOR_UPPER_TORQUE=?,LIFT_MOTOR_TORQUE_SLEEP=?"
			",LIFT_MOTOR_UPPER_TEMP=?,LIFT_MOTOR_TEMP_SLEEP=?,LIFT_MOTOR_SPEED_SET=?,ONE_CLICK_BACK_LOCATION=?,AUTO_SWITCH_OPEN_BATTERY_THRE=?"
			",AUTO_SWITCH_OPEN_VOL_THRE=?,IS_AUTO_FLUSH=?,FLUSH_RFID1=?,FLUSH_RFID2=?,FLUSH_PLACE_OFFSET=?"
			",ALARM_STOP_TIME=?,CHARGE_YTPRESET=?,OBSTACLE_CFG=?,IS_HAVE_FLUSH=?,COLLECT_TIME=?,VOICE_OFFSET=?,VOICE_AVERIGE_TIME=?"
		" WHERE ROBOT_HOST_ID=?";

	cData.addValue("IP_ADDRESS", pDevData->m_sRobotIp);
	cData.addValue("PORT_NUMBER", pDevData->m_sRobotPort);
	cData.addValue("ROBOT_NAME", pDevData->m_sRobName);
	cData.addValue("ROBOT_RUN_SPEED", pDevData->m_dRobRunSpeed);
	cData.addValue("ROBOT_RUN_SPEEDZ", pDevData->m_dRobRunSpeedZ);

	cData.addValue("DEVICE_ENUM", pDevData->m_nDeviceEnum);
	cData.addValue("ROBOT_TYPE", pDevData->m_nRobType);
	cData.addValue("SAFE_DISTANCE", pDevData->m_dSafeDistance);
	cData.addValue("ROBOT_WORK_TYPE", pDevData->m_nRobWorkType);
	cData.addValue("CORSE", pDevData->m_dCorse);

	cData.addValue("PROXIMITY_SENSOR_OFFSET", pDevData->m_nProximitySensorOffset);
	cData.addValue("NO2_LABEL_OFFSET", pDevData->m_nNo2LabelOffset);
	cData.addValue("IS_OPEN_AUTO_CHARGEL", pDevData->m_nIsOpenAutoCharge);
	cData.addValue("AUTO_CHARGE_THRESHOLD", pDevData->m_nAutoChargeThreshold);
	cData.addValue("RETURN_SPEED", pDevData->m_dReturnSpeed);

	cData.addValue("FRONT_OBSTACLE_AVOIDANCE", pDevData->m_dFrontObstacleAvoidance);
	cData.addValue("BACK_OBSTACLE_AVOIDANCE", pDevData->m_dBackObstanceAvidance);
	cData.addValue("CHARGE_CUTOFF_THRESHOLD", pDevData->m_dChargeCutOffThreshold);
	cData.addValue("CHARGE_CUTOFF_VOLTAGE", pDevData->m_dChargeCutOffVolTage);
	cData.addValue("HOLDING_ADDPOWER_THRESHOLD", pDevData->m_dHoldingAddPowerThreshold);

	cData.addValue("HOLDING_ADDPOWER_VOLTAGE", pDevData->m_dHoldingAddPowerVoltage);
	cData.addValue("TASK_ELE_QUANTITY_THRESHOLD", pDevData->m_dTaskEleQuantityThreshold);
	cData.addValue("TASK_ELE_QUANTITY_VOLTAGE", pDevData->m_dTaskEleQuantityVoltage);
	cData.addValue("FORCE_CHARGE_THRESHOLD", pDevData->m_dForceChargeThreshold);
	cData.addValue("FORCE_CHARGE_VOLTAGE", pDevData->m_dForceChargeVoltage);

	cData.addValue("CHARGE_FAIL_LOOP_COUNT", pDevData->m_dChargeFallLoopCount);
	cData.addValue("CHARGE_COMMUNICATION_DELAY", pDevData->m_dChargeCommunicationDelay);
	cData.addValue("CHARGE_AUTO_RETORN_DISTANCE", pDevData->m_dChargeAutoRetornDistance);
	cData.addValue("LEVEL_ONE_SPEED_CUT", pDevData->m_dLevelOneSpeedCut);
	cData.addValue("LEVEL_TWO_SPEED_CUT", pDevData->m_dLevelTwoSpeedCut);

	cData.addValue("DRIVE_MOTOR_UPPER_CURRENT", pDevData->m_dDriveMotorUpperCurrent);
	cData.addValue("DRIVE_MOTOR_CURRENT_SLEEP", pDevData->m_dDriveMotorCurrentSleep);
	cData.addValue("DRIVE_MOTOR_UPPER_TORQUE", pDevData->m_dDriveMotorUpperTorque);
	cData.addValue("DRIVE_MOTOR_TORQUE_SLEEP", pDevData->m_dDriveMotorTorqueSleep);
	cData.addValue("DRIVE_MOTOR_UPPER_TEMP", pDevData->m_dDriveMotorUpperTemp);

	cData.addValue("DRIVE_MOTOR_TEMP_SLEEP", pDevData->m_dDriveMotorTempSleep);
	cData.addValue("LIFT_MOTOR_UPPER_CURRENT", pDevData->m_dLiftMotorUpperCurrent);
	cData.addValue("LIFT_MOTOR_CURRENT_SLEEP", pDevData->m_dLiftMotorCurrentSleep);
	cData.addValue("LIFT_MOTOR_UPPER_TORQUE", pDevData->m_dLiftMotorUpperTorque);
	cData.addValue("LIFT_MOTOR_TORQUE_SLEEP", pDevData->m_dLiftMotorTorqueSleep);

	cData.addValue("LIFT_MOTOR_UPPER_TEMP", pDevData->m_dLiftMotorUpperTemp);
	cData.addValue("LIFT_MOTOR_TEMP_SLEEP", pDevData->m_dLiftMotorTempSleep);
	cData.addValue("LIFT_MOTOR_SPEED_SET", pDevData->m_dLiftMotorSleepSet);
	cData.addValue("ONE_CLICK_BACK_LOCATION", pDevData->m_dOneClickBaceLocation);
	cData.addValue("AUTO_SWITCH_OPEN_BATTERY_THRE", pDevData->m_dAutoSwitchOpenBatteryThre);

	cData.addValue("AUTO_SWITCH_OPEN_VOL_THRE", pDevData->m_dAutoSwitchOpenVolThre);
	cData.addValue("IS_AUTO_FLUSH", pDevData->m_dIsAutoFlush);
	cData.addValue("FLUSH_RFID1", pDevData->m_nFlushRFID1);
	cData.addValue("FLUSH_RFID2", pDevData->m_nFlushRFID2);
	cData.addValue("FLUSH_PLACE_OFFSET", pDevData->m_dFlushPlaceOffset);


	cData.addValue("ALARM_STOP_TIME", pDevData->m_nAlarmStopTime);
	cData.addValue("CHARGE_YTPRESET", pDevData->m_nChargeYTPreset);
	cData.addValue("OBSTACLE_CFG", pDevData->m_sRobObstacleCfg);
	cData.addValue("IS_HAVE_FLUSH", pDevData->m_nIsHaveFlush);
	cData.addValue("COLLECT_TIME", pDevData->m_nCollectTime);
	cData.addValue("VOICE_OFFSET", pDevData->m_nVoiceOffset);
	cData.addValue("VOICE_AVERIGE_TIME", pDevData->m_nVoiceAverigeTime);
	//cData.addValue("HUM_ENABLE", pDevData->m_nHumEnable);

	cData.addValue("ROBOT_HOST_ID", pDevData->m_sDevGuid);

	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}

bool updatePanTiltConfig(CDevDataCam* pDevData, QString& sErrMsg)
{
	CDatabaseExecData cData;
	cData.sTableName = "prob_pan_tilt_config";
	cData.sSql = "UPDATE prob_pan_tilt_config SET USER_NAME=?,PAN_TILT_IP=?,PAN_TILT_PORT=?,PASSWORD=?,MANUAL_RECORD_PATH=?,BROADCAST_TIME=? "
		" WHERE ROBOT_HOST_ID=?";

	cData.addValue("USER_NAME", pDevData->m_sUserName);
	cData.addValue("PAN_TILT_IP", pDevData->m_sCamerIp);
	cData.addValue("PAN_TILT_PORT", pDevData->m_nCamerPort);
	cData.addValue("PASSWORD", pDevData->m_sPassWord);
	cData.addValue("MANUAL_RECORD_PATH", pDevData->m_sRecordPath);
	cData.addValue("BROADCAST_TIME", pDevData->m_nBroadcastTime);
	cData.addValue("ROBOT_HOST_ID", pDevData->m_sRobHostGuid);

	bool bRet = CPublicData::instance().m_pSqlDllOper->exec(cData);
	sErrMsg = cData.sErr;
	return bRet;
}
